Bug 1355625 - Part 2: Tweak the Gradle build to agree more with moz.build. r=sebastian
MozReview-Commit-ID: DMoxPnla3Ij
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -31,16 +31,20 @@ android {
vectorDrawables.useSupportLibrary = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
+ aaptOptions {
+ cruncherEnabled = false
+ }
+
dexOptions {
javaMaxHeapSize "2g"
}
lintOptions {
abortOnError true
}
@@ -139,16 +143,22 @@ android {
srcDir "${topsrcdir}/mobile/android/base/aidl"
}
java {
srcDir "${topsrcdir}/mobile/android/base/java"
srcDir "${topsrcdir}/mobile/android/search/java"
srcDir "${topsrcdir}/mobile/android/services/src/main/java"
+ // These aren't included in moz.build builds, for reasons unknown.
+ exclude "org/mozilla/gecko/dlc/CleanupAction.java"
+ // This is a marker file for linting. We can probably find
+ // other ways to achieve this once we're Gradle-only.
+ exclude "org/mozilla/gecko/util/UnusedResourcesUtil.java"
+
if (mozconfig.substs.MOZ_ANDROID_MLS_STUMBLER) {
srcDir "${topsrcdir}/mobile/android/stumbler/java"
}
if (!mozconfig.substs.MOZ_CRASHREPORTER) {
exclude 'org/mozilla/gecko/CrashReporter.java'
}
@@ -156,16 +166,17 @@ android {
exclude 'org/mozilla/gecko/ChromeCastDisplay.java'
exclude 'org/mozilla/gecko/ChromeCastPlayer.java'
exclude 'org/mozilla/gecko/GeckoMediaPlayer.java'
exclude 'org/mozilla/gecko/GeckoPresentationDisplay.java'
exclude 'org/mozilla/gecko/MediaPlayerManager.java'
}
if (mozconfig.substs.MOZ_WEBRTC) {
+ srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/base/java/src"
srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src"
srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src"
srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/modules/video_render/android/java/src"
}
if (mozconfig.substs.MOZ_INSTALL_TRACKING) {
exclude 'org/mozilla/gecko/adjust/StubAdjustHelper.java'
} else {
@@ -546,8 +557,22 @@ android.applicationVariants.all { varian
.each { it.replaceNode {} }
manifestOutFile.write(XmlUtil.serialize(xml), 'UTF-8')
}
})
}
}
}
+
+// Bug 1355625: strip extra .class files from Gradle builds; modified from
+// http://stackoverflow.com/a/40705699.
+android.applicationVariants.all { variant ->
+ variant.javaCompile.doLast {
+ // BuildConfig is not part of release builds, but it is required by the
+ // local unit tests of the android-test job. Since the debug buildType
+ // is overloaded as the release type (see comments above), we have to
+ // keep the BuildConfig for testing.
+ // delete fileTree(dir: "${project.buildDir}", include: '**/org/mozilla/gecko/BuildConfig.class')
+ delete fileTree(dir: "${project.buildDir}", include: '**/org/mozilla/gecko/Manifest.class')
+ delete fileTree(dir: "${project.buildDir}", include: '**/org/mozilla/gecko/Manifest$permission.class')
+ }
+}
--- a/mobile/android/thirdparty/build.gradle
+++ b/mobile/android/thirdparty/build.gradle
@@ -64,8 +64,16 @@ idea {
excludeDirs += file('com/leanplum')
}
}
}
// Bug 1353055 - Strip 'vars' debugging information to agree with moz.build.
apply from: "${topsrcdir}/mobile/android/gradle/debug_level.gradle"
android.libraryVariants.all configureVariantDebugLevel
+
+// Bug 1355625: strip extra .class files from Gradle builds; modified from
+// http://stackoverflow.com/a/40705699.
+android.libraryVariants.all { variant ->
+ variant.javaCompile.doLast {
+ delete fileTree(dir: "${project.buildDir}", include: "**/org/mozilla/gecko/thirdparty_unused/BuildConfig.class")
+ }
+}
--- a/settings.gradle
+++ b/settings.gradle
@@ -48,8 +48,14 @@ if (json.substs.MOZ_ANDROID_PACKAGE_INST
// The Gradle instance is shared between settings.gradle and all the
// other build.gradle files (see
// http://forums.gradle.org/gradle/topics/define_extension_properties_from_settings_xml).
// We use this ext property to pass the per-object-directory mozconfig
// between scripts. This lets us execute set-up code before we gradle
// tries to configure the project even once, and as a side benefit
// saves invoking |mach environment| multiple times.
gradle.ext.mozconfig = json
+
+if (!gradle.ext.mozconfig.substs.COMPILE_ENVIRONMENT) {
+ // These should really come from the included binaries, but that's not easy.
+ gradle.ext.mozconfig.substs.TARGET_XPCOM_ABI = 'arm-eabi-gcc3'
+}
+gradle.ext.mozconfig.substs.MOZ_APP_ABI = gradle.ext.mozconfig.substs.TARGET_XPCOM_ABI