From: Daniel Martí Date: Mon, 26 Aug 2013 10:57:18 +0000 (+0200) Subject: Add subdir support to gradle X-Git-Tag: 0.1~430 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=09b76a0bf4217a7ac736bc4a96be8ff3f6aefc3f;p=fdroidserver.git Add subdir support to gradle --- diff --git a/docs/fdroid.texi b/docs/fdroid.texi index 86e1324d..924ecff9 100644 --- a/docs/fdroid.texi +++ b/docs/fdroid.texi @@ -923,11 +923,14 @@ example). @item maven=yes Build with maven instead of ant -@item gradle= +@item gradle=[@] Build with gradle instead of ant, specifying what flavour to assemble. If is 'yes', 'main' or empty, no flavour will be used. Note that this will not work on projects with flavours, since it will build all flavours and there will be no 'main' build. +If @ is attached to , then the gradle tasks will be run in that +directory. This might be necessary if gradle needs to be run in the parent +directory, in which case one would use 'gradle=@..'. @item preassemble= Space-separated list of gradle tasks to be run before the assemble task diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 467f6fc6..07e637dc 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -428,19 +428,30 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d mvncmd += thisbuild['mvnflags'] p = subprocess.Popen(mvncmd, cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) elif 'gradle' in thisbuild: - flavour = thisbuild['gradle'] + if '@' in thisbuild['gradle']: + flavour = thisbuild['gradle'].split('@')[0] + gradle_dir = thisbuild['gradle'].split('@')[1] + gradle_dir = os.path.join(root_dir, gradle_dir) + else: + flavour = thisbuild['gradle'] + gradle_dir = root_dir + if 'compilesdk' in thisbuild: level = thisbuild["compilesdk"].split('-')[1] subprocess.call(['sed', '-i', 's@compileSdkVersion[ ]*[0-9]*@compileSdkVersion '+level+'@g', 'build.gradle'], cwd=root_dir) + if '@' in thisbuild['gradle']: + subprocess.call(['sed', '-i', + 's@compileSdkVersion[ ]*[0-9]*@compileSdkVersion '+level+'@g', + 'build.gradle'], cwd=gradle_dir) - for root, dirs, files in os.walk(root_dir): - root = os.path.relpath(root, root_dir) + for root, dirs, files in os.walk(gradle_dir): + root = os.path.relpath(root, gradle_dir) for f in files: if f == 'build.gradle': - adapt_gradle(os.path.join(root_dir, root, f), verbose) + adapt_gradle(os.path.join(gradle_dir, root, f), verbose) continue if flavour in ['main', 'yes', '']: @@ -456,9 +467,9 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d commands += ['assemble'+flavour+'Release'] if verbose: - print "Running %s on %s" % (" ".join(commands), root_dir) + print "Running %s on %s" % (" ".join(commands), gradle_dir) - p = subprocess.Popen(commands, cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(commands, cwd=gradle_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: if install: antcommands = ['debug','install']