@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
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', '']:
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']