diff --git a/docs/fdroid.texi b/docs/fdroid.texi index 64b1ca96..4e87eaf3 100644 --- a/docs/fdroid.texi +++ b/docs/fdroid.texi @@ -1028,6 +1028,13 @@ builds happen correctly. List of Gradle tasks to be run before the assemble task in a Gradle project build. +@item gradleprops=[,,...] +List of Gradle properties to pass via the command line to Gradle. A property +can be of the form @code{foo} or of the form @code{key=value}. + +For example: @code{gradleprops=enableFoo,someSetting=bar} will result in +@code{gradle -PenableFoo -PsomeSetting=bar}. + @item antcommands=[,,...] Specify an alternate set of Ant commands (target) instead of the default 'release'. It can't be given any flags, such as the path to a build.xml. diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 4695097b..0c2d67dd 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -516,6 +516,9 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d adapt_gradle(libpath) cmd = [config['gradle']] + if thisbuild['gradleprops']: + cmd += ['-P'+kv for kv in thisbuild['gradleprops']] + for task in gradletasks: parts = task.split(':') parts[-1] = 'clean' + capitalize_intact(parts[-1]) @@ -711,9 +714,13 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d with open(os.path.join(root_dir, 'build.gradle'), "a") as f: f.write("\nandroid { lintOptions { checkReleaseBuilds false } }\n") - commands = [config['gradle']] + gradletasks + cmd = [config['gradle']] + if thisbuild['gradleprops']: + cmd += ['-P'+kv for kv in thisbuild['gradleprops']] - p = FDroidPopen(commands, cwd=root_dir) + cmd += gradletasks + + p = FDroidPopen(cmd, cwd=root_dir) elif thisbuild['type'] == 'ant': logging.info("Building Ant project...") diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 09a5d07f..ae20c472 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -105,6 +105,7 @@ flag_defaults = OrderedDict([ ('buildjni', []), ('ndk', 'r10e'), # defaults to latest ('preassemble', []), + ('gradleprops', []), ('antcommands', None), ('novcheck', False), ]) @@ -522,7 +523,8 @@ def metafieldtype(name): def flagtype(name): if name in ['extlibs', 'srclibs', 'patch', 'rm', 'buildjni', 'preassemble', - 'update', 'scanignore', 'scandelete', 'gradle', 'antcommands']: + 'update', 'scanignore', 'scandelete', 'gradle', 'antcommands', + 'gradleprops']: return 'list' if name in ['init', 'prebuild', 'build']: return 'script'