Skip to content

Commit

Permalink
Bug 1411688 - Part 1: Make --with-gradle handle single-locale repacks…
Browse files Browse the repository at this point in the history
…. 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

--HG--
extra : rebase_source : 6a34a8c299138ea39c6703f334c8fd5f49b03237
  • Loading branch information
ncalexan committed Oct 23, 2017
1 parent e5ebccd commit 9de930d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ if ('multi' == System.env.AB_CD) {
// 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}"
Expand Down
43 changes: 25 additions & 18 deletions mobile/android/gradle/with_gecko_binaries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,32 @@ ext.configureVariantWithJNIWrappers = { variant, module ->
// 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') {
Expand Down
1 change: 1 addition & 0 deletions toolkit/mozapps/installer/upload-files-APK.mk
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ repackage_fennec = \
$(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))

Expand Down

0 comments on commit 9de930d

Please sign in to comment.