mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1352602 - Part 2: Use build system SDK versions in Gradle configurations. r=maliu
This patch does two things: - add a Gradle-only ANDROID_COMPILE_SDK_VERSION substitution; - uses it while uniformizing all of the Gradle Android SDK version configurations. The approach is fairly standard (and we were using it already); see, for example https://medium.com/@ali.muzaffar/gradle-configure-variables-for-all-android-project-modules-in-one-place-5a6e56cd384e This will make bumping the Gradle configuration versions forward easier. MozReview-Commit-ID: 1j5siCvR5qt --HG-- extra : rebase_source : 07afb00de0e4a72af4026eb19ff4f2530c119336
This commit is contained in:
parent
23b90d5c28
commit
bd230aea82
21
build.gradle
21
build.gradle
@ -1,11 +1,32 @@
|
||||
import java.util.regex.Pattern
|
||||
|
||||
def tryInt = { string ->
|
||||
if (string == null) {
|
||||
return string
|
||||
}
|
||||
if (string.isInteger()) {
|
||||
return string as Integer
|
||||
}
|
||||
return string
|
||||
}
|
||||
|
||||
allprojects {
|
||||
// Expose the per-object-directory configuration to all projects.
|
||||
ext {
|
||||
mozconfig = gradle.mozconfig
|
||||
topsrcdir = gradle.mozconfig.topsrcdir
|
||||
topobjdir = gradle.mozconfig.topobjdir
|
||||
|
||||
compileSdkVersion = tryInt(mozconfig.substs.ANDROID_COMPILE_SDK_VERSION)
|
||||
buildToolsVersion = tryInt(mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION)
|
||||
targetSdkVersion = tryInt(mozconfig.substs.ANDROID_TARGET_SDK)
|
||||
minSdkVersion = tryInt(mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION)
|
||||
manifestPlaceholders = [
|
||||
ANDROID_PACKAGE_NAME: mozconfig.substs.ANDROID_PACKAGE_NAME,
|
||||
ANDROID_TARGET_SDK: mozconfig.substs.ANDROID_TARGET_SDK,
|
||||
MOZ_ANDROID_MIN_SDK_VERSION: mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION,
|
||||
MOZ_ANDROID_SHARED_ID: "${mozconfig.substs.ANDROID_PACKAGE_NAME}.sharedID",
|
||||
]
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -230,9 +230,10 @@ fi
|
||||
])
|
||||
|
||||
dnl Configure an Android SDK.
|
||||
dnl Arg 1: target SDK version, like 23.
|
||||
dnl Arg 2: list of build-tools versions, like "23.0.3 23.0.1".
|
||||
dnl Arg 3: target lint version, like "25.3.1" (note: we fall back to
|
||||
dnl Arg 1: compile SDK version, like 23.
|
||||
dnl Arg 2: target SDK version, like 23.
|
||||
dnl Arg 3: list of build-tools versions, like "23.0.3 23.0.1".
|
||||
dnl Arg 4: target lint version, like "25.3.1" (note: we fall back to
|
||||
dnl unversioned lint if this version is not found).
|
||||
AC_DEFUN([MOZ_ANDROID_SDK],
|
||||
[
|
||||
@ -257,7 +258,7 @@ case "$target" in
|
||||
AC_MSG_ERROR([Including platforms/android-* in --with-android-sdk arguments is deprecated. Use --with-android-sdk=$android_sdk_root.])
|
||||
fi
|
||||
|
||||
android_target_sdk=$1
|
||||
android_target_sdk=$2
|
||||
AC_MSG_CHECKING([for Android SDK platform version $android_target_sdk])
|
||||
android_sdk=$android_sdk_root/platforms/android-$android_target_sdk
|
||||
if ! test -e "$android_sdk/source.properties" ; then
|
||||
@ -268,7 +269,7 @@ case "$target" in
|
||||
AC_MSG_CHECKING([for Android build-tools])
|
||||
android_build_tools_base="$android_sdk_root"/build-tools
|
||||
android_build_tools_version=""
|
||||
for version in $2; do
|
||||
for version in $3; do
|
||||
android_build_tools="$android_build_tools_base"/$version
|
||||
if test -d "$android_build_tools" -a -f "$android_build_tools/aapt"; then
|
||||
android_build_tools_version=$version
|
||||
@ -277,7 +278,7 @@ case "$target" in
|
||||
fi
|
||||
done
|
||||
if test "$android_build_tools_version" = ""; then
|
||||
version=$(echo $2 | cut -d" " -f1)
|
||||
version=$(echo $3 | cut -d" " -f1)
|
||||
AC_MSG_ERROR([You must install the Android build-tools version $version. Try |mach bootstrap|. (Looked for "$android_build_tools_base"/$version)])
|
||||
fi
|
||||
|
||||
@ -324,11 +325,15 @@ case "$target" in
|
||||
AC_MSG_ERROR([The program emulator was not found. Try |mach bootstrap|.])
|
||||
fi
|
||||
|
||||
# `compileSdkVersion ANDROID_COMPILE_SDK_VERSION` is Gradle-only,
|
||||
# so there's no associated configure check.
|
||||
ANDROID_COMPILE_SDK_VERSION=$1
|
||||
ANDROID_TARGET_SDK="${android_target_sdk}"
|
||||
ANDROID_SDK="${android_sdk}"
|
||||
ANDROID_SDK_ROOT="${android_sdk_root}"
|
||||
ANDROID_TOOLS="${android_tools}"
|
||||
ANDROID_BUILD_TOOLS_VERSION="$android_build_tools_version"
|
||||
AC_SUBST(ANDROID_COMPILE_SDK_VERSION)
|
||||
AC_SUBST(ANDROID_TARGET_SDK)
|
||||
AC_SUBST(ANDROID_SDK_ROOT)
|
||||
AC_SUBST(ANDROID_SDK)
|
||||
@ -357,7 +362,7 @@ case "$target" in
|
||||
;;
|
||||
esac
|
||||
|
||||
android_lint_target=$3
|
||||
android_lint_target=$4
|
||||
ANDROID_LINT_CLASSPATH=""
|
||||
android_lint_versioned_jar="$ANDROID_SDK_ROOT/tools/lib/lint-$android_lint_target.jar"
|
||||
android_lint_unversioned_jar="$ANDROID_SDK_ROOT/tools/lib/lint.jar"
|
||||
|
@ -11,20 +11,17 @@ dexcount {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION
|
||||
compileSdkVersion project.ext.compileSdkVersion
|
||||
buildToolsVersion project.ext.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
targetSdkVersion 23
|
||||
minSdkVersion 15
|
||||
targetSdkVersion project.ext.targetSdkVersion
|
||||
minSdkVersion project.ext.minSdkVersion
|
||||
manifestPlaceholders = project.ext.manifestPlaceholders
|
||||
|
||||
applicationId mozconfig.substs.ANDROID_PACKAGE_NAME
|
||||
testApplicationId 'org.mozilla.roboexample.test'
|
||||
testInstrumentationRunner 'org.mozilla.gecko.FennecInstrumentationTestRunner'
|
||||
manifestPlaceholders = [
|
||||
ANDROID_PACKAGE_NAME: mozconfig.substs.ANDROID_PACKAGE_NAME,
|
||||
MOZ_ANDROID_MIN_SDK_VERSION: mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION,
|
||||
MOZ_ANDROID_SHARED_ID: "${mozconfig.substs.ANDROID_PACKAGE_NAME}.sharedID",
|
||||
]
|
||||
// Used by Robolectric based tests; see TestRunner.
|
||||
buildConfigField 'String', 'BUILD_DIR', "\"${project.buildDir}\""
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="${MOZ_ANDROID_MIN_SDK_VERSION}"
|
||||
android:targetSdkVersion="23"/>
|
||||
android:targetSdkVersion="${ANDROID_TARGET_SDK}"/>
|
||||
<!-- TODO: re-instate maxSdkVersion. -->
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
@ -3,12 +3,14 @@ buildDir "${topobjdir}/gradle/build/mobile/android/bouncer"
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION
|
||||
compileSdkVersion project.ext.compileSdkVersion
|
||||
buildToolsVersion project.ext.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
targetSdkVersion 23
|
||||
minSdkVersion 15
|
||||
targetSdkVersion project.ext.targetSdkVersion
|
||||
minSdkVersion project.ext.minSdkVersion
|
||||
manifestPlaceholders = project.ext.manifestPlaceholders
|
||||
|
||||
applicationId mozconfig.substs.ANDROID_PACKAGE_NAME
|
||||
}
|
||||
|
||||
|
@ -6,17 +6,19 @@ apply plugin: 'com.android.library'
|
||||
def VERSION_NAME = '0.0.1'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION
|
||||
compileSdkVersion project.ext.compileSdkVersion
|
||||
buildToolsVersion project.ext.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
targetSdkVersion project.ext.targetSdkVersion
|
||||
minSdkVersion project.ext.minSdkVersion
|
||||
manifestPlaceholders = project.ext.manifestPlaceholders
|
||||
|
||||
// TODO: version GeckoView explicitly. We'd like to avoid
|
||||
// mozconfig.substs.ANDROID_VERSION_CODE, which won't be intuitive to
|
||||
// consumer (and advances very quickly on pre-release channels).
|
||||
versionCode 1
|
||||
versionName VERSION_NAME
|
||||
targetSdkVersion 23
|
||||
minSdkVersion 15
|
||||
consumerProguardFiles 'proguard-rules.txt'
|
||||
|
||||
// TODO: ensure these fields always agree with mobile/android/geckoview/BuildConfig.java.in,
|
||||
|
@ -3,13 +3,15 @@ buildDir "${topobjdir}/gradle/build/mobile/android/geckoview_example"
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION
|
||||
compileSdkVersion project.ext.compileSdkVersion
|
||||
buildToolsVersion project.ext.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
targetSdkVersion project.ext.targetSdkVersion
|
||||
minSdkVersion project.ext.minSdkVersion
|
||||
manifestPlaceholders = project.ext.manifestPlaceholders
|
||||
|
||||
applicationId "org.mozilla.geckoview_example"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
9
mobile/android/thirdparty/build.gradle
vendored
9
mobile/android/thirdparty/build.gradle
vendored
@ -3,12 +3,13 @@ buildDir "${topobjdir}/gradle/build/mobile/android/thirdparty"
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION
|
||||
compileSdkVersion project.ext.compileSdkVersion
|
||||
buildToolsVersion project.ext.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
targetSdkVersion 23
|
||||
minSdkVersion 15
|
||||
targetSdkVersion project.ext.targetSdkVersion
|
||||
minSdkVersion project.ext.minSdkVersion
|
||||
manifestPlaceholders = project.ext.manifestPlaceholders
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
@ -2302,7 +2302,7 @@ dnl ========================================================
|
||||
if test -z "$gonkdir" ; then
|
||||
case "$MOZ_BUILD_APP" in
|
||||
mobile/android)
|
||||
MOZ_ANDROID_SDK(23, 23.0.3 23.0.1, 25.3.1)
|
||||
MOZ_ANDROID_SDK(23, 23, 23.0.3 23.0.1, 25.3.1)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user