diff --git a/build.gradle b/build.gradle index 94d92b8f55bbf..68922a84930f6 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,9 @@ allprojects { } repositories { - jcenter() + maven { + url gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY + } } } @@ -17,8 +19,9 @@ buildDir "${topobjdir}/gradle/build" buildscript { repositories { - jcenter() - + maven { + url gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY + } } dependencies { diff --git a/configure.in b/configure.in index 1b6b5fb6e138e..00c1b910885f9 100644 --- a/configure.in +++ b/configure.in @@ -5374,12 +5374,56 @@ if test -n "$MOZ_OMX_PLUGIN"; then fi dnl ======================================================== -dnl = Enable building mobile/android with Gradle -dnl ======================================================== -MOZ_ARG_ENABLE_BOOL(gradle-mobile-android-builds, -[ --enable-gradle-mobile-android-builds Enable building mobile/android with Gradle], - MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE=1, - MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE=) +dnl Gradle support +dnl +dnl If --with-gradle is specified, build mobile/android with Gradle. +dnl +dnl If no Gradle binary is specified, use the in tree Gradle wrapper. +dnl The wrapper downloads and installs Gradle, which is good for local +dnl developers but not good in automation. +dnl ======================================================== + +GRADLE= +MOZ_ARG_WITH_STRING(gradle, +[ --with-gradle=/path/to/bin/gradle + Enable building mobile/android with Gradle (argument: location of binary or wrapper (gradle/gradlew))], + if test "$withval" = "no" ; then + dnl --without-gradle => use the wrapper in |mach gradle|, don't build + dnl with Gradle by default. + GRADLE=$srcdir/gradlew + MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE= + elif test "$withval" = "yes" ; then + dnl --with-gradle => use the wrapper in |mach gradle|, build with + dnl Gradle by default. + GRADLE=$srcdir/gradlew + MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE=1 + else + dnl --with-gradle=/path/to/gradle => use the given binary in |mach + dnl gradle|, build with Gradle by default. + GRADLE=$withval + MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE=1 + fi + , + dnl No --with{out}-gradle => use the wrapper in |mach gradle|, don't build + dnl with Gradle by default. + GRADLE=$srcdir/gradlew + MOZ_BUILD_MOBILE_ANDROID_WITH_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) + +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) if test -n "$MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE"; then if test "$OS_TARGET" = "Android" -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then diff --git a/mobile/android/mach_commands.py b/mobile/android/mach_commands.py index 11cafbdcbbbb4..108a03cb72714 100644 --- a/mobile/android/mach_commands.py +++ b/mobile/android/mach_commands.py @@ -57,7 +57,7 @@ def gradle(self, args): # Avoid logging the command self.log_manager.terminal_handler.setLevel(logging.CRITICAL) - return self.run_process(['./gradlew'] + args, + return self.run_process([self.substs['GRADLE']] + args, 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))