From 1ef3e2408ac26996a24f65aafab900de443b028a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Mon, 4 Nov 2013 16:09:23 +0100 Subject: [PATCH] Implement forceversion and forcevercode for gradle projects --- fdroidserver/common.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 11d820d4..0dd733ee 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1502,19 +1502,31 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path, for path in manifest_paths(root_dir, flavour): if not os.path.isfile(path): continue - if subprocess.call(['sed','-i', - 's/android:versionName="[^"]*"/android:versionName="' + build['version'] + '"/g', - path]) != 0: - raise BuildException("Failed to amend manifest") + if path.endswith('.xml'): + if subprocess.call(['sed','-i', + 's/android:versionName="[^"]*"/android:versionName="' + build['version'] + '"/g', + path]) != 0: + raise BuildException("Failed to amend manifest") + elif path.endswith('.gradle'): + if subprocess.call(['sed','-i', + 's/versionName[ ]*=[ ]*"[^"]*"/versionName = "' + build['version'] + '"/g', + path]) != 0: + raise BuildException("Failed to amend build.gradle") if 'forcevercode' in build: print "Changing the version code..." for path in manifest_paths(root_dir, flavour): if not os.path.isfile(path): continue - if subprocess.call(['sed','-i', - 's/android:versionCode="[^"]*"/android:versionCode="' + build['vercode'] + '"/g', - path]) != 0: - raise BuildException("Failed to amend manifest") + if path.endswith('.xml'): + if subprocess.call(['sed','-i', + 's/android:versionCode="[^"]*"/android:versionCode="' + build['vercode'] + '"/g', + path]) != 0: + raise BuildException("Failed to amend manifest") + elif path.endswith('.gradle'): + if subprocess.call(['sed','-i', + 's/versionCode[ ]*=[ ]*[0-9]*/versionCode = ' + build['vercode'] + '/g', + path]) != 0: + raise BuildException("Failed to amend build.gradle") # Delete unwanted files... if 'rm' in build: -- 2.30.2