chiark / gitweb /
Add subdir support to gradle
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 26 Aug 2013 10:57:18 +0000 (12:57 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 26 Aug 2013 10:57:18 +0000 (12:57 +0200)
docs/fdroid.texi
fdroidserver/build.py

index 86e1324d3ee2406f468692bb0dfb8afbb080ea6f..924ecff9c74b072bf318ced253c0c94b1728b3db 100644 (file)
@@ -923,11 +923,14 @@ example).
 @item maven=yes
 Build with maven instead of ant
 
-@item gradle=<flavour>
+@item gradle=<flavour>[@<dir>]
 Build with gradle instead of ant, specifying what flavour to assemble.
 If <flavour> 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 @<dir> is attached to <flavour>, 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=<flavour>@..'.
 
 @item preassemble=<task1> <task2>
 Space-separated list of gradle tasks to be run before the assemble task
index 467f6fc6a96631d420b0a2d3a46828c48ac1aaf0..07e637dce41667976451177301254493040a4290 100644 (file)
@@ -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']