Bug 1411686 - Part 1: Force Gradle to run during |mach package|. r=maliu
It looks like I didn't handle this flow -- which only matters during
l10n multi-locale builds and l10n single-locale repacks -- during the
initial Gradle landing. Now we need to handle it.
Remember that the l10n process runs |mach build && mach package|, and
then modifies the object directory by inserting new localized resource
files. It then runs |mach package| again and expects to regenerate
the ap_ file, ready to splice it into the existing apk file. The
existing code just copied the .ap_ built by Gradle without
regenerating the ap_ file. This commit forces running Gradle again,
which will pick up the new resources in the object directory.
The chain of dependencies is:
|mach package| > gecko-nodeps.ap_ > .aapt.nodeps > .gradle.deps
and the latter two targets are FORCE, so they always get run
(regardless of the freshness of the inputs).
In fact, this runs the entire Gradle process again, including
producing classes.dex. (The moz.build process doesn't compile the
Java source code again.) This patch changes the existing behaviour to
copy the regenerated classes.dex into the repacked apk and avoid the
need for the R.java IDs to line up across the |mach build| and |mach
package| invocations. This turned out to be necessary to support
multi-locale builds with newer Gradle versions, which don't appear to
preserve aapt R.java IDs across the
|mach build|, |mach package|, |mach compare-locales|, |mach package|
chain.
MozReview-Commit-ID: FlhtQPwR5xG
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -236,24 +236,29 @@ library_jars := \
# separate clause for MMA (Leanplum) support.
ifdef MOZ_INSTALL_TRACKING
library_jars += $(ANDROID_SDK)/optional/org.apache.http.legacy.jar
endif # MOZ_INSTALL_TRACKING
library_jars := $(subst $(NULL) ,:,$(strip $(library_jars)))
ifdef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
-.gradle.deps: .aapt.deps FORCE
- @$(TOUCH) $@
- $(topsrcdir)/mach gradle \
+define gradle_command
+$(1): $(2)
+ @$$(TOUCH) $$@
+ $$(topsrcdir)/mach gradle \
geckoview:generateJNIWrappersForGeneratedRelease \
app:generateJNIWrappersForFennecOfficialPhotonDebug \
app:assembleOfficialPhotonDebug \
app:assembleOfficialPhotonDebugAndroidTest \
-x lint
+endef
+
+# .gradle.deps: .aapt.deps FORCE
+$(eval $(call gradle_command,.gradle.deps,.aapt.deps FORCE))
classes.dex: .gradle.deps
$(REPORT_BUILD)
cp $(gradle_dir)/app/intermediates/transforms/dex/officialPhoton/debug/folders/1000/1f/main/classes.dex $@
GeneratedJNIWrappers.cpp GeneratedJNIWrappers.h GeneratedJNINatives.h : .gradle.deps
$(REPORT_BUILD)
@@ -496,18 +501,28 @@ endef
# don't want the packaging step to write anything that would make a
# further no-op build do work. See also
# toolkit/mozapps/installer/packager.mk.
# .aapt.deps: $(all_resources)
$(eval $(call aapt_command,.aapt.deps,$(all_resources),gecko.ap_,generated/,./))
ifdef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
-.aapt.nodeps: FORCE
+
+# It's not quite "no dependencies": nodeps means that it doesn't
+# depend on the generated resources that incorporate l10n, principally
+# strings.xml.
+
+# .gradle.nodeps: AndroidManifest.xml generated/preprocessed/org/mozilla/gecko/AppConstants.java ... FORCE
+$(eval $(call gradle_command,.gradle.nodeps,AndroidManifest.xml $(constants_PP_JAVAFILES) FORCE))
+
+.aapt.nodeps: .gradle.nodeps FORCE
+ @$(TOUCH) $@
cp $(gradle_dir)/app/intermediates/res/resources-official-photon-debug.ap_ gecko-nodeps.ap_
+ cp $(gradle_dir)/app/intermediates/transforms/dex/officialPhoton/debug/folders/1000/1f/main/classes.dex classes.dex
else
# .aapt.nodeps: AndroidManifest.xml FORCE
$(eval $(call aapt_command,.aapt.nodeps,AndroidManifest.xml FORCE,gecko-nodeps.ap_,gecko-nodeps/,gecko-nodeps/))
endif
# Override the Java settings with some specific android settings
include $(topsrcdir)/config/android-common.mk