Bug 1247375 - Part 2: Add build system Gradle defines for Fennec. r=glandium

Enable building with Gradle using --with-gradle.  Configure the
location of Gradle with --with-gradle=/path/to/gradle.  For local
developers, this is always the in tree Gradle wrapper, which downloads
and installs the correct Gradle version automatically.  In automation,
this will be a version of Gradle fetched from tooltool.

Configure the location to use to download Gradle Maven dependencies
(including the Android-Gradle plugin) by setting
GRADLE_MAVEN_REPOSITORY in your mozconfig. For local developers, this
defaults to the jcenter repository.  In automation, this will be an
archived directory fetched from tooltool.

Android-specific Maven dependencies are shipped as "extras" with the
Android SDK, and should be found automatically by the Android-Gradle
plugin.

MozReview-Commit-ID: Hrkn88Vig5H

--HG--
extra : rebase_source : c5e83590c9b28ad5a10f91ec0a3663e6d64b3b40
extra : amend_source : c3e162673238d6c6191838cc98f8301e325e01a2
This commit is contained in:
Nick Alexander 2016-02-10 19:29:27 -08:00
parent 1c95416d9a
commit 9d87131d31
3 changed files with 56 additions and 9 deletions

View File

@ -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 {

View File

@ -5374,12 +5374,56 @@ if test -n "$MOZ_OMX_PLUGIN"; then
fi
dnl ========================================================
dnl = Enable building 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 ========================================================
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=)
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

View File

@ -57,7 +57,7 @@ class MachCommands(MachCommandBase):
# 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))