From: Daniel Martí Date: Tue, 13 Aug 2013 13:20:11 +0000 (+0200) Subject: Implement --install for gradle, add compilesdk= X-Git-Tag: 0.1~457^2~4 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=bc27ebcb82a236f3df2ad925b5d4b5ec2fe9a1d1;p=fdroidserver.git Implement --install for gradle, add compilesdk= --- diff --git a/docs/fdroid.texi b/docs/fdroid.texi index 1f0de51a..ff4861c8 100644 --- a/docs/fdroid.texi +++ b/docs/fdroid.texi @@ -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= +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. diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 5f0056ec..3d0a0836 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -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']