no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / mobile / android / gradle / with_gecko_binaries.gradle
blob0f47e89414420cc18972e32418951e6b2486253d
1 /* -*- Mode: Groovy; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // The JNI wrapper generation tasks depend on the JAR creation task of the :annotations project.
7 evaluationDependsOn(':annotations')
9 // Whether to include compiled artifacts: `lib/**/*.so` and `assets/omni.ja`.
10 // Multi-locale packaging wants to include compiled artifacts but *not* rebuild
11 // them: see also `rootProject.{machStagePackage,geckoBinariesOnlyIf}`.
12 def hasCompileArtifacts() {
13     return project.mozconfig.substs.COMPILE_ENVIRONMENT // Full builds.
14         || project.mozconfig.substs.MOZ_ARTIFACT_BUILDS // Artifact builds.
15         || System.getenv("MOZ_CHROME_MULTILOCALE") // Multi-locale packaging.
18 ext.configureVariantWithGeckoBinaries = { variant ->
19     if (hasCompileArtifacts()) {
20         // Local (read, not 'official') builds want to reflect developer changes to
21         // the omnijar sources, and (when compiling) to reflect developer changes to
22         // the native binaries.  To do this, the Gradle build calls out to the
23         // moz.build system, which can be re-entrant.  Official builds are driven by
24         // the moz.build system and should never be re-entrant in this way.
25         def assetGenTask = tasks.findByName("generate${variant.name.capitalize()}Assets")
26         def jniLibFoldersTask = tasks.findByName("merge${variant.name.capitalize()}JniLibFolders")
27         if (!mozconfig.substs.MOZILLA_OFFICIAL && (variant.productFlavors*.name).contains('withGeckoBinaries')) {
28             assetGenTask.dependsOn rootProject.machStagePackage
29             jniLibFoldersTask.dependsOn rootProject.machStagePackage
30         }
31     }
34 ext.configureLibraryVariantWithJNIWrappers = { variant, module ->
35     // BundleLibRuntime prepares the library for further processing to be
36     // incorporated in an app. We use this version to create the JNI wrappers.
37     def jarTask = tasks["bundleLibRuntimeToJar${variant.name.capitalize()}"]
38     def bundleJar = jarTask.outputs.files.find({ it.name == 'classes.jar' })
40     def annotationProcessorsJarTask = project(':annotations').jar
42     def wrapperTask
43     if (System.env.IS_LANGUAGE_REPACK == '1') {
44         // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and don't
45         // really have a build environment.
46         wrapperTask = task("generateJNIWrappersFor${module}${variant.name.capitalize()}")
47     } else {
48         wrapperTask = task("generateJNIWrappersFor${module}${variant.name.capitalize()}", type: JavaExec) {
49             classpath annotationProcessorsJarTask.archiveFile
50         
51             // Configure the classpath at evaluation-time, not at
52             // configuration-time: see above comment.
53             doFirst {
54                 classpath variant.javaCompileProvider.get().classpath
55             }
56     
57             mainClass = 'org.mozilla.gecko.annotationProcessors.AnnotationProcessor'
58             args module
59             args bundleJar
60             
61             workingDir "${topobjdir}/widget/android"
63             inputs.file(bundleJar)
64             inputs.file(annotationProcessorsJarTask.archiveFile)
65             inputs.property("module", module)
67             outputs.file("${topobjdir}/widget/android/GeneratedJNINatives.h")
68             outputs.file("${topobjdir}/widget/android/GeneratedJNIWrappers.cpp")
69             outputs.file("${topobjdir}/widget/android/GeneratedJNIWrappers.h")
71             dependsOn jarTask
72             dependsOn annotationProcessorsJarTask
73         }
74     }
76     if (module == 'Generated') {
77         tasks["bundle${variant.name.capitalize()}Aar"].dependsOn wrapperTask
78     } else {
79         tasks["assemble${variant.name.capitalize()}"].dependsOn wrapperTask
80     }