From b114b440200004a369f533e5e305fd6e42b19200 Mon Sep 17 00:00:00 2001 From: Marcus Hoffmann Date: Sat, 26 Aug 2017 12:55:34 +0200 Subject: [PATCH] handle gradle-plugin 3.0 output apk location This commit adds support for new gradle plugin 3.0 output directories. The new structure looks like this: build/outputs/apk//release/*.apk Note the capitalization on the different flavour components. So if we build a specific flavour combination we add this combination to the path where we look for an output .apk. Closes #363 Based on !320 by: Michel Le Bihan Signed-off-by: Marcus Hoffmann --- fdroidserver/build.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 3123a4ae..c43b18fd 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -275,14 +275,13 @@ def force_gradle_build_tools(build_dir, build_tools): path) -def capitalize_intact(string): - """Like str.capitalize(), but leave the rest of the string intact without - switching it to lowercase.""" +def transform_first_char(string, method): + """Uses method() on the first character of string.""" if len(string) == 0: return string if len(string) == 1: - return string.upper() - return string[0].upper() + string[1:] + return method(string) + return method(string[0]) + string[1:] def has_native_code(apkobj): @@ -444,7 +443,7 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext if flavours == ['yes']: flavours = [] - flavours_cmd = ''.join([capitalize_intact(flav) for flav in flavours]) + flavours_cmd = ''.join([transform_first_char(flav, str.upper) for flav in flavours]) gradletasks += ['assemble' + flavours_cmd + 'Release'] @@ -803,11 +802,14 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext elif omethod == 'gradle': src = None - for apks_dir in [ - os.path.join(root_dir, 'build', 'outputs', 'apk', 'release'), - os.path.join(root_dir, 'build', 'outputs', 'apk'), - os.path.join(root_dir, 'build', 'apk'), - ]: + apk_dirs = [ + os.path.join(root_dir, 'build', 'outputs', 'apk', 'release'), + os.path.join(root_dir, 'build', 'outputs', 'apk'), + os.path.join(root_dir, 'build', 'apk'), + ] + if flavours_cmd: + apk_dirs.append(os.path.join(root_dir, 'build', 'outputs', 'apk', transform_first_char(flavours_cmd, str.lower), 'release')) + for apks_dir in apk_dirs: for apkglob in ['*-release-unsigned.apk', '*-unsigned.apk', '*.apk']: apks = glob.glob(os.path.join(apks_dir, apkglob))