Bug 1234629 - Post: Add Gradle support for bouncer. r=me
☠☠ backed out by 1836c1f9ef19 ☠ ☠
authorNick Alexander <nalexander@mozilla.com>
Tue, 26 Jan 2016 11:54:00 -0800
changeset 283150 54a3d0851bc60d26fb4744c605787031070052c8
parent 283149 f80912ecfa87584394d22e28ed09e68c182d1b35
child 283151 400c030d3c01d8818fe07d4547e0c145e19f099e
push id29975
push userphilringnalda@gmail.com
push dateSat, 06 Feb 2016 02:27:56 +0000
treeherdermozilla-central@6148b5848349 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1234629
milestone47.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 1234629 - Post: Add Gradle support for bouncer. r=me
mobile/android/app/build.gradle
mobile/android/bouncer/Makefile.in
mobile/android/bouncer/build.gradle
settings.gradle
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -61,17 +61,19 @@ android {
         automation {
         }
     }
 
     sourceSets {
         main {
             manifest.srcFile "${topobjdir}/mobile/android/base/AndroidManifest.xml"
             assets {
-                if (mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY) {
+                if (mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY && !mozconfig.substs.MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER) {
+                    // If we are packaging the bouncer, it will have the distribution, so don't put
+                    // it in the main APK as well.
                     srcDir "${mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets"
                 }
             }
         }
 
         androidTest {
             java {
                 srcDir "${topsrcdir}/mobile/android/tests/browser/robocop/src"
--- a/mobile/android/bouncer/Makefile.in
+++ b/mobile/android/bouncer/Makefile.in
@@ -17,9 +17,14 @@ manifest := $(srcdir)/AndroidManifest.xm
 manifest_TARGET := export
 # Special 'cuz they are set in mobile/android/defs.mk.
 manifest_FLAGS += \
   -DMOZ_ANDROID_SHARED_ID="$(MOZ_ANDROID_SHARED_ID)" \
   -DMOZ_ANDROID_SHARED_ACCOUNT_TYPE="$(MOZ_ANDROID_SHARED_ACCOUNT_TYPE)" \
   -DMOZ_ANDROID_SHARED_FXACCOUNT_TYPE="$(MOZ_ANDROID_SHARED_FXACCOUNT_TYPE)" \
   $(NULL)
 
+# Targets built very early during a Gradle build.
+gradle-targets: $(abspath AndroidManifest.xml)
+
+.PHONY: gradle-targets
+
 libs:: $(ANDROID_APK_NAME).apk
new file mode 100644
--- /dev/null
+++ b/mobile/android/bouncer/build.gradle
@@ -0,0 +1,76 @@
+buildDir "${topobjdir}/gradle/build/mobile/android/bouncer"
+
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 23
+    buildToolsVersion "23.0.1"
+
+    defaultConfig {
+        targetSdkVersion 23
+        minSdkVersion 15 
+        applicationId mozconfig.substs.ANDROID_PACKAGE_NAME
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_7
+        targetCompatibility JavaVersion.VERSION_1_7
+    }
+ 
+    dexOptions {
+        javaMaxHeapSize "2g"
+    }
+
+    lintOptions {
+        abortOnError false
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+        }
+    }
+
+    sourceSets {
+        main {
+            manifest.srcFile "${topobjdir}/mobile/android/bouncer/AndroidManifest.xml"
+            assets {
+                if (mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY) {
+                    srcDir "${mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets"
+                }
+            }
+            java {
+                srcDir 'java'
+            }
+            res {
+                srcDir "${topsrcdir}/${mozconfig.substs.MOZ_BRANDING_DIRECTORY}/res" // For the icon.
+                srcDir 'res'
+            }
+        }
+    }
+}
+
+task generateCodeAndResources(type:Exec) {
+    workingDir "${topobjdir}"
+
+    commandLine mozconfig.substs.GMAKE
+    args '-C'
+    args "${topobjdir}/mobile/android/bouncer"
+    args 'gradle-targets'
+
+    // Only show the output if something went wrong.
+    ignoreExitValue = true
+    standardOutput = new ByteArrayOutputStream()
+    errorOutput = standardOutput
+    doLast {
+        if (execResult.exitValue != 0) {
+            throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
+        }
+    }
+}
+
+afterEvaluate {
+    android.applicationVariants.all {
+        preBuild.dependsOn generateCodeAndResources
+    }
+}
--- a/settings.gradle
+++ b/settings.gradle
@@ -33,16 +33,21 @@ include ':base'
 include ':omnijar'
 include ':thirdparty'
 
 project(':app').projectDir = new File("${json.topsrcdir}/mobile/android/app")
 project(':base').projectDir = new File("${json.topsrcdir}/mobile/android/app/base")
 project(':omnijar').projectDir = new File("${json.topsrcdir}/mobile/android/app/omnijar")
 project(':thirdparty').projectDir = new File("${json.topsrcdir}/mobile/android/thirdparty")
 
+if (json.substs.MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER) {
+    include ':bouncer'
+    project(':bouncer').projectDir = new File("${json.topsrcdir}/mobile/android/bouncer")
+}
+
 // 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