Bug 1411688 - Part 1: Make --with-gradle handle single-locale repacks. r=snorp
☠☠ backed out by a73e202ca31d ☠ ☠
authorNick Alexander <nalexander@mozilla.com>
Mon, 23 Oct 2017 13:24:58 -0700
changeset 390122 34f83aab44e6c0a68a448c3c10f61267c0eb649e
parent 390121 2e4e139bb5d7586ae8cb67bf2450dcaec4ba1255
child 390123 866854a996b8671c8fbe1f7f6e2cfc3329727ae2
push id32806
push userarchaeopteryx@coole-files.de
push dateSat, 04 Nov 2017 09:56:48 +0000
treeherdermozilla-central@52b2b0d65a90 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1411688
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1411688 - Part 1: Make --with-gradle handle single-locale repacks. r=snorp Single-locale repacks do the following: Download existing APK; unzip APK; update l10n resources; |mach package| with IS_LANGUAGE_REPACK=1. This is pretty hard to accommodate, but we can try. The key issues here are to recognize when IS_LANGUAGE_REPACK=1 and not ask for l10n resources (in particular, strings.xml) to be generated. We do need to include the freshly built classes.dex when repackaging, because newer Gradle/aapt doesn't preserve the R.java IDs. MozReview-Commit-ID: 9FvQtmPOUjg
build.gradle
mobile/android/gradle/with_gecko_binaries.gradle
toolkit/mozapps/installer/upload-files-APK.mk
--- a/build.gradle
+++ b/build.gradle
@@ -62,16 +62,20 @@ if ('multi' == System.env.AB_CD) {
     // Multi-l10n builds set `AB_CD=multi`, which isn't a valid locale.  This
     // causes the
     //
     // |mach build| > |mach gradle| > |make gradle-targets| > AndroidManifest.xml > strings.xml > multi/brand.dtd
     //
     // dependency chain to fail, since multi isn't a real locale.  To avoid
     // this, if Gradle is invoked with AB_CD=multi, we don't invoke Make at all.
     task generateCodeAndResources()
+} else if (System.env.IS_LANGUAGE_REPACK == '1') {
+    // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and handle resource
+    // and code generation themselves.
+    task generateCodeAndResources()
 } else {
     task generateCodeAndResources(type:Exec) {
         workingDir "${topobjdir}"
 
         commandLine mozconfig.substs.GMAKE
         args '-C'
         args "${topobjdir}/mobile/android/base"
         args 'gradle-targets'
--- a/mobile/android/gradle/with_gecko_binaries.gradle
+++ b/mobile/android/gradle/with_gecko_binaries.gradle
@@ -147,35 +147,42 @@ ext.configureVariantWithJNIWrappers = { 
     // by configuring the classpath at evaluation-time, not configuration-time.
     //
     // The specific dependency on the `prepareDependencies` task may not be
     // necessary, but commits like
     // https://github.com/evant/gradle-retrolambda/commit/15108c65ee43be499a1359d9d4f88b0851d46769
     // suggest that it is.  It certainly doesn't hurt.
     def prepareDependenciesTask = tasks.getByName("prepare${variant.name.capitalize()}Dependencies")
 
-    def wrapperTask = task("generateJNIWrappersFor${module}${variant.name.capitalize()}", type: JavaExec) {
-        classpath "${topobjdir}/build/annotationProcessors/annotationProcessors.jar"
-
-        // Configure the classpath at evaluation-time, not at
-        // configuration-time: see above comment.
-        doFirst {
-            classpath variant.javaCompile.classpath
-            // Include android.jar.
-            classpath variant.javaCompile.options.bootClasspath
+    def wrapperTask
+    if (System.env.IS_LANGUAGE_REPACK == '1') {
+        // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and don't
+        // really have a build environment.
+        wrapperTask = task("generateJNIWrappersFor${module}${variant.name.capitalize()}")
+    } else {
+        wrapperTask = task("generateJNIWrappersFor${module}${variant.name.capitalize()}", type: JavaExec) {
+            classpath "${topobjdir}/build/annotationProcessors/annotationProcessors.jar"
+    
+            // Configure the classpath at evaluation-time, not at
+            // configuration-time: see above comment.
+            doFirst {
+                classpath variant.javaCompile.classpath
+                // Include android.jar.
+                classpath variant.javaCompile.options.bootClasspath
+            }
+    
+            main = 'org.mozilla.gecko.annotationProcessors.AnnotationProcessor'
+            args module
+            args jarTask.outputs.files.iterator().next()
+    
+            workingDir "${topobjdir}/mobile/android/base"
+    
+            dependsOn jarTask
+            dependsOn prepareDependenciesTask
         }
-
-        main = 'org.mozilla.gecko.annotationProcessors.AnnotationProcessor'
-        args module
-        args jarTask.outputs.files.iterator().next()
-
-        workingDir "${topobjdir}/mobile/android/base"
-
-        dependsOn jarTask
-        dependsOn prepareDependenciesTask
     }
 
     if (module == 'Generated') {
         tasks["bundle${variant.name.capitalize()}"].dependsOn wrapperTask
     } else {
         tasks["assemble${variant.name.capitalize()}"].dependsOn wrapperTask
     }
 }
--- a/toolkit/mozapps/installer/upload-files-APK.mk
+++ b/toolkit/mozapps/installer/upload-files-APK.mk
@@ -89,16 +89,17 @@ package_fennec = \
 repackage_fennec = \
   $(MAKE) -C $(GECKO_APP_AP_PATH) gecko-nodeps.ap_ && \
   $(PYTHON) -m mozbuild.action.package_fennec_apk \
     --verbose \
     --inputs \
       $(UNPACKAGE) \
       $(GECKO_APP_AP_PATH)/gecko-nodeps.ap_ \
     --omnijar $(MOZ_PKG_DIR)/$(OMNIJAR_NAME) \
+    --classes-dex $(GECKO_APP_AP_PATH)/classes.dex \
     --output $(PACKAGE:.apk=-unsigned-unaligned.apk) && \
   $(call RELEASE_SIGN_ANDROID_APK,$(PACKAGE:.apk=-unsigned-unaligned.apk),$(PACKAGE))
 
 INNER_MAKE_PACKAGE = $(if $(UNPACKAGE),$(repackage_fennec),$(package_fennec))
 
 # Language repacks root the resources contained in assets/omni.ja
 # under assets/, but the repacks expect them to be rooted at /.
 # Therefore, we we move the omnijar back to / so the resources are