Skip to content

Commit

Permalink
Bug 1247375 - Part 2: Add build system Gradle defines for Fennec. r=g…
Browse files Browse the repository at this point in the history
…landium

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
  • Loading branch information
ncalexan committed Feb 11, 2016
1 parent 1c95416 commit 9d87131
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 10 deletions.
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ allprojects {
}

repositories {
jcenter()
maven {
url gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY
}
}
}

buildDir "${topobjdir}/gradle/build"

buildscript {
repositories {
jcenter()

maven {
url gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY
}
}

dependencies {
Expand Down
56 changes: 50 additions & 6 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mobile/android/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 9d87131

Please sign in to comment.