chiark / gitweb /
Implement --install for gradle, add compilesdk=
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 13 Aug 2013 13:20:11 +0000 (15:20 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 13 Aug 2013 13:20:11 +0000 (15:20 +0200)
docs/fdroid.texi
fdroidserver/build.py

index 1f0de51aeaf255adf038f46b53df05a17ef18b2e..ff4861c89e8a6aade3a95a240aaaa1076e407a68 100644 (file)
@@ -772,6 +772,14 @@ already exist, but not a good idea if it's heavily customised. If you get an
 error about invalid target, first try @code{init=rm -rf bin/}; otherwise this 
 parameter should do the trick.
 
+Please note that gradle builds should be using compilesdk=.
+
+@item compilesdk=<level>
+Practically accomplishes the same that target= does when used in ant and maven
+projects. compilesdk= is used rather than target= so as to not cause any more
+confusion. It only takes effect on gradle builds in the build.gradle file,
+thus using it in any other case is not wise.
+
 @item update=xxx
 By default, 'android update project' is used to generate or update the
 build.xml file. Specifying update=no bypasses that.
index 5f0056ec95a143d2c301e31716ea0527ae33b168..3d0a08362538c1747acbb9fcf5cfc88afe3bdc6b 100644 (file)
@@ -417,7 +417,27 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
         p = subprocess.Popen(mvncmd, cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     elif 'gradle' in thisbuild:
         flavour = thisbuild['gradle']
-        p = subprocess.Popen([gradle, 'assemble'+flavour+'Release'], cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+        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)
+
+        subprocess.call(['sed', '-i',
+                's@buildToolsVersion[ ]*["\'][0-9\.]*["\']@buildToolsVersion "'+build_tools+'"@g',
+                'build.gradle'], cwd=root_dir)
+
+        subprocess.call(['sed', '-i',
+                's@com.android.tools.build:gradle:[0-9\.\+]*@com.android.tools.build:gradle:'+target+'@g',
+                'build.gradle'], cwd=root_dir)
+        
+        if install:
+            commands = [gradle, 'assemble'+flavour+'Debug', 'install'+flavour+'Debug']
+        else:
+            commands = [gradle, 'assemble'+flavour+'Release']
+
+        p = subprocess.Popen(commands, cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     else:
         if install:
             antcommands = ['debug','install']