Bug 1254353 - Pre: Add GRADLE_FLAGS to control Gradle in automation. r?chmanchester draft
authorNick Alexander <nalexander@mozilla.com>
Mon, 14 Mar 2016 12:54:26 -0700
changeset 341306 a6e25d8ace5811ce099508946caee114043d0cc6
parent 341305 52233f609ba25f4fed958867ed680472a08e18f5
child 341307 03618be13b789a028be2c31a8d5b7d0481bf0289
push id13184
push usernalexander@mozilla.com
push dateWed, 16 Mar 2016 21:07:46 +0000
reviewerschmanchester
bugs1254353
milestone48.0a1
Bug 1254353 - Pre: Add GRADLE_FLAGS to control Gradle in automation. r?chmanchester MozReview-Commit-ID: KwUumRoJ4c5
mobile/android/config/mozconfigs/common
mobile/android/mach_commands.py
old-configure.in
--- a/mobile/android/config/mozconfigs/common
+++ b/mobile/android/config/mozconfigs/common
@@ -39,16 +39,17 @@ ANDROID_NDK_VERSION_32BIT="r8c"
 ac_add_options --enable-application=mobile/android
 ac_add_options --with-android-ndk="$topsrcdir/android-ndk"
 ac_add_options --with-android-sdk="$topsrcdir/android-sdk-linux"
 
 # Build with Gradle everywhere.  Gradle and the Maven repository are installed
 # using tooltool.
 ac_add_options --with-gradle="$topsrcdir/gradle/bin/gradle"
 export GRADLE_MAVEN_REPOSITORY="file://$topsrcdir/jcentral"
+export GRADLE_FLAGS="--no-daemon --offline --debug"
 
 ac_add_options --with-android-gnu-compiler-version=4.9
 ac_add_options --with-android-version=9
 ac_add_options --with-system-zlib
 ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
 
 # Treat warnings as errors (modulo ALLOW_COMPILER_WARNINGS).
 ac_add_options --enable-warnings-as-errors
--- a/mobile/android/mach_commands.py
+++ b/mobile/android/mach_commands.py
@@ -2,16 +2,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import argparse
 import logging
 import os
+import shlex
 
 import mozpack.path as mozpath
 
 from mozbuild.base import (
     MachCommandBase,
     MachCommandConditions as conditions,
 )
 
@@ -58,26 +59,28 @@ class MachCommands(MachCommandBase):
         self.log_manager.terminal_handler.setLevel(logging.CRITICAL)
 
 
         # In automation, JAVA_HOME is set via mozconfig, which needs
         # to be specially handled in each mach command. This turns
         # $JAVA_HOME/bin/java into $JAVA_HOME.
         java_home = os.path.dirname(os.path.dirname(self.substs['JAVA']))
 
+        gradle_flags = shlex.split(self.substs.get('GRADLE_FLAGS', ''))
+
         # We force the Gradle JVM to run with the UTF-8 encoding, since we
         # filter strings.xml, which is really UTF-8; the ellipsis character is
         # replaced with ??? in some encodings (including ASCII).  It's not yet
         # possible to filter with encodings in Gradle
         # (https://github.com/gradle/gradle/pull/520) and it's challenging to
         # do our filtering with Gradle's Ant support.  Moreover, all of the
         # Android tools expect UTF-8: see
         # http://tools.android.com/knownissues/encoding.  See
         # http://stackoverflow.com/a/21267635 for discussion of this approach.
-        return self.run_process([self.substs['GRADLE']] + args,
+        return self.run_process([self.substs['GRADLE']] + gradle_flags + args,
             append_env={
                 'GRADLE_OPTS': '-Dfile.encoding=utf-8',
                 'JAVA_HOME': java_home,
             },
             pass_thru=True, # Allow user to run gradle interactively.
             ensure_exit_code=False, # Don't throw on non-zero exit code.
             cwd=mozpath.join(self.topsrcdir))
 
--- a/old-configure.in
+++ b/old-configure.in
@@ -4695,16 +4695,17 @@ MOZ_ARG_WITH_STRING(gradle,
     )
 
 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" ; then
     if test -z "$GRADLE" -o ! -x "$GRADLE" ; then
         AC_MSG_ERROR([The program gradlew/gradle was not found.  Use --with-gradle=/path/to/bin/gradle}])
     fi
 fi
 AC_SUBST(GRADLE)
+AC_SUBST(GRADLE_FLAGS)
 
 dnl Path to Maven repository containing Gradle dependencies.  Automation will
 dnl set this to file:///path/to/local via the mozconfig.  Local developer
 dnl default is jcenter.
 if test -z "$GRADLE_MAVEN_REPOSITORY" ; then
     GRADLE_MAVEN_REPOSITORY=https://jcenter.bintray.com/
 fi
 AC_SUBST(GRADLE_MAVEN_REPOSITORY)