Bug 1208793 - Part 3: Remove 'preprocessed_resources' Gradle project. r=sebastian
authorNick Alexander <nalexander@mozilla.com>
Mon, 19 Oct 2015 18:06:10 -0700
changeset 303720 d12ef59cbae5529866519f80a07138d1f8cc858d
parent 303719 eae251eb922efb66b0fd985f92c8e52f1a16d430
child 303721 27b83dafe62594dfafb630af5e13f9c806137a12
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1208793
milestone44.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 1208793 - Part 3: Remove 'preprocessed_resources' Gradle project. r=sebastian While testing, I found some issues with the existing dependencies. To address them, I've made all project preBuild tasks depend on the (single) root generateCodeAndResources; this should ensure that the Make integration happens as early as possible. In addition, I fixed the dependencies syncing the generated resources into the build directory, which weren't quite right. This works well locally now.
mobile/android/gradle/base/build.gradle
mobile/android/gradle/build.gradle
mobile/android/gradle/preprocessed_resources/AndroidManifest.xml
mobile/android/gradle/preprocessed_resources/build.gradle
mobile/android/gradle/settings.gradle
mobile/android/mach_commands.py
--- a/mobile/android/gradle/base/build.gradle
+++ b/mobile/android/gradle/base/build.gradle
@@ -46,16 +46,18 @@ android {
                     srcDir 'src/webrtc_video_render'
                 }
 
                 // Adjust helpers are included in the preprocessed_code project.
                 exclude 'org/mozilla/gecko/adjust/**'
             }
 
             res {
+                srcDir "src/branding/res"
+                srcDir "${project.buildDir}/generated/source/preprocessed_resources" // See syncPreprocessedResources.
                 if (mozconfig.substs.MOZ_CRASHREPORTER) {
                     srcDir "src/crashreporter/res"
                 }
             }
         }
 
         test {
             java {
@@ -64,30 +66,38 @@ android {
 
             resources {
                 srcDir "resources/background_junit4"
             }
         }
     }
 }
 
+task syncPreprocessedResources(type: Sync, dependsOn: rootProject.generateCodeAndResources) {
+    into("${project.buildDir}/generated/source/preprocessed_resources")
+    from("${topobjdir}/mobile/android/base/res")
+}
+
+android.libraryVariants.all { variant ->
+    variant.preBuild.dependsOn syncPreprocessedResources
+}
+
 dependencies {
     compile 'com.android.support:support-v4:23.0.1'
     compile 'com.android.support:appcompat-v7:23.0.1'
     compile 'com.android.support:recyclerview-v7:23.0.1'
 
     if (mozconfig.substs.MOZ_NATIVE_DEVICES) {
         compile 'com.android.support:mediarouter-v7:22.2.1'
         compile 'com.google.android.gms:play-services-basement:8.1.0'
         compile 'com.google.android.gms:play-services-base:8.1.0'
         compile 'com.google.android.gms:play-services-cast:8.1.0'
     }
 
     compile project(':preprocessed_code')
-    compile project(':preprocessed_resources')
     compile project(':thirdparty')
 
     testCompile 'junit:junit:4.12'
     testCompile 'org.robolectric:robolectric:3.0'
     testCompile 'org.simpleframework:simple-http:4.1.13'
 }
 
 apply plugin: 'idea'
--- a/mobile/android/gradle/build.gradle
+++ b/mobile/android/gradle/build.gradle
@@ -77,20 +77,20 @@ gradle.taskGraph.beforeTask {
 }
 
 afterEvaluate {
     subprojects {
         if (!hasProperty('android')) {
             return
         }
         android.applicationVariants.all {
-            checkManifest.dependsOn rootProject.generateCodeAndResources
+            preBuild.dependsOn rootProject.generateCodeAndResources
         }
         android.libraryVariants.all {
-            checkManifest.dependsOn rootProject.generateCodeAndResources
+            preBuild.dependsOn rootProject.generateCodeAndResources
         }
     }
 }
 
 apply plugin: 'idea'
 
 idea {
     project {
deleted file mode 100644
--- a/mobile/android/gradle/preprocessed_resources/AndroidManifest.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.mozilla.gecko.preprocessed_resources">
-
-</manifest>
deleted file mode 100644
--- a/mobile/android/gradle/preprocessed_resources/build.gradle
+++ /dev/null
@@ -1,41 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
-    compileSdkVersion 23
-    buildToolsVersion "23.0.1"
-
-    defaultConfig {
-        targetSdkVersion 22
-        minSdkVersion 9
-    }
-
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
-    }
-
-    lintOptions {
-        abortOnError false
-    }
-
-    sourceSets {
-        main {
-            res {
-                srcDir "${project.buildDir}/generated/source/preprocessed_resources"
-                srcDir "src/branding/res"
-            }
-        }
-    }
-}
-
-task syncPreprocessedResources(type: Sync) {
-    into("${project.buildDir}/generated/source/preprocessed_resources")
-    from("${topobjdir}/mobile/android/base/res")
-}
-
-android.libraryVariants.all { variant ->
-    // variant does not expose its generate debug res values task.
-    def name = variant.buildType.name
-    def generateResValuesTask = tasks.findByName("generate${name.capitalize()}ResValues")
-    generateResValuesTask.dependsOn syncPreprocessedResources
-}
--- a/mobile/android/gradle/settings.gradle
+++ b/mobile/android/gradle/settings.gradle
@@ -22,25 +22,23 @@ if (proc.exitValue() != 0) {
 import groovy.json.JsonSlurper
 def slurper = new JsonSlurper()
 def json = slurper.parseText(standardOutput.toString())
 
 include ':app'
 include ':base'
 include ':omnijar'
 include ':preprocessed_code'
-include ':preprocessed_resources'
 include ':thirdparty'
 
 def gradleRoot = new File("${json.topobjdir}/mobile/android/gradle")
 project(':app').projectDir = new File(gradleRoot, 'app')
 project(':base').projectDir = new File(gradleRoot, 'base')
 project(':omnijar').projectDir = new File(gradleRoot, 'omnijar')
 project(':preprocessed_code').projectDir = new File(gradleRoot, 'preprocessed_code')
-project(':preprocessed_resources').projectDir = new File(gradleRoot, 'preprocessed_resources')
 project(':thirdparty').projectDir = new File(gradleRoot, 'thirdparty')
 
 if (json.substs.MOZ_INSTALL_TRACKING) {
     include ':thirdparty_adjust_sdk'
     project(':thirdparty_adjust_sdk').projectDir = new File(gradleRoot, 'thirdparty_adjust_sdk')
 }
 
 // The Gradle instance is shared between settings.gradle and all the
--- a/mobile/android/mach_commands.py
+++ b/mobile/android/mach_commands.py
@@ -102,20 +102,16 @@ class MachCommands(MachCommandBase):
             'local.properties',
             defines=defines,
             deps=os.path.join(self.topobjdir, 'mobile/android/gradle/.deps/local.properties.pp'))
 
         srcdir('preprocessed_code/build.gradle', 'mobile/android/gradle/preprocessed_code/build.gradle')
         srcdir('preprocessed_code/src/main/AndroidManifest.xml', 'mobile/android/gradle/preprocessed_code/AndroidManifest.xml')
         srcdir('preprocessed_code/src/adjust/java/org/mozilla/gecko/adjust', 'mobile/android/base/adjust')
 
-        srcdir('preprocessed_resources/build.gradle', 'mobile/android/gradle/preprocessed_resources/build.gradle')
-        srcdir('preprocessed_resources/src/main/AndroidManifest.xml', 'mobile/android/gradle/preprocessed_resources/AndroidManifest.xml')
-        srcdir('preprocessed_resources/src/branding/res', os.path.join(self.substs['MOZ_BRANDING_DIRECTORY'], 'res'))
-
         srcdir('thirdparty/build.gradle', 'mobile/android/gradle/thirdparty/build.gradle')
         srcdir('thirdparty/src/main/AndroidManifest.xml', 'mobile/android/gradle/thirdparty/AndroidManifest.xml')
         srcdir('thirdparty/src/main/java', 'mobile/android/thirdparty')
 
         srcdir('thirdparty_adjust_sdk/build.gradle', 'mobile/android/gradle/thirdparty_adjust_sdk/build.gradle')
         srcdir('thirdparty_adjust_sdk/src/main/AndroidManifest.xml', 'mobile/android/gradle/thirdparty_adjust_sdk/AndroidManifest.xml')
 
         srcdir('omnijar/build.gradle', 'mobile/android/gradle/omnijar/build.gradle')
@@ -147,16 +143,17 @@ class MachCommands(MachCommandBase):
         srcdir('base/src/main/java/org/mozilla/search', 'mobile/android/search/java/org/mozilla/search')
         srcdir('base/src/main/java/org/mozilla/javaaddons', 'mobile/android/javaaddons/java/org/mozilla/javaaddons')
         srcdir('base/src/webrtc_audio_device/java', 'media/webrtc/trunk/webrtc/modules/audio_device/android/java/src')
         srcdir('base/src/webrtc_video_capture/java', 'media/webrtc/trunk/webrtc/modules/video_capture/android/java/src')
         srcdir('base/src/webrtc_video_render/java', 'media/webrtc/trunk/webrtc/modules/video_render/android/java/src')
         srcdir('base/src/main/res', 'mobile/android/base/resources')
         srcdir('base/src/main/assets', 'mobile/android/app/assets')
         srcdir('base/src/crashreporter/res', 'mobile/android/base/crashreporter/res')
+        srcdir('base/src/branding/res', os.path.join(self.substs['MOZ_BRANDING_DIRECTORY'], 'res'))
         # JUnit 4 test code.
         srcdir('base/src/background_junit4', 'mobile/android/tests/background/junit4/src')
         srcdir('base/resources/background_junit4', 'mobile/android/tests/background/junit4/resources')
 
         manifest_path = os.path.join(self.topobjdir, 'mobile', 'android', 'gradle.manifest')
         with FileAvoidWrite(manifest_path) as f:
             m.write(fileobj=f)