Skip to content

Commit 8586084

Browse files
committed
Temp hack to get --add-source working for Gradle builds.
1 parent ad3f82e commit 8586084

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pythonforandroid/toolchain.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def build_dist_from_args(ctx, dist, args):
202202
info('Building WITHOUT debugging symbols (--release option used)')
203203

204204
ctx.distribution = dist
205+
205206
ctx.prepare_bootstrap(bs)
206207
if dist.needs_build:
207208
ctx.prepare_dist()
@@ -213,6 +214,21 @@ def build_dist_from_args(ctx, dist, args):
213214
),
214215
)
215216

217+
# Temporary hack
218+
# Moves extra sources into the src/main/java dir
219+
# until we can determine a better solution with gradle.
220+
for i in range(len(args.unknown_args)):
221+
arg = args.unknown_args[i]
222+
if arg == '--add-source' and i < len(args.unknown_args):
223+
adir = args.unknown_args[i+1]
224+
files = glob.glob(os.path.join(adir, '**'))
225+
for afile in files:
226+
rel_path = afile.replace(adir + '/', '')
227+
dest_path = os.path.join(ctx.javaclass_dir, rel_path)
228+
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
229+
info("Copying {} to {}".format(afile, dest_path))
230+
shutil.copy(afile, dest_path)
231+
216232
ctx.bootstrap.run_distribute()
217233

218234
info_main('# Your distribution was created successfully, exiting.')

0 commit comments

Comments
 (0)