Bug 1220887 - Make 'base' Gradle project in the srcdir. r?sebastian draft
authorNick Alexander <nalexander@mozilla.com>
Mon, 02 Nov 2015 14:55:00 -0800
changeset 306270 a8ebdff5869b8d5d85da6fc774a2ef4b73386969
parent 306269 b423610b2e44ba5b63458608d4f78c979d970e77
child 306271 dc8b84f6f10f2c7f6f565646a1ecb291e88315d4
push id7104
push usernalexander@mozilla.com
push dateTue, 03 Nov 2015 19:23:22 +0000
reviewerssebastian
bugs1220887
milestone45.0a1
Bug 1220887 - Make 'base' Gradle project in the srcdir. r?sebastian This is the last Gradle project that isn't in the srcdir. Since base/ doesn't have the correct package prefix directory structure, we still need to symlink, but we only need one link. This effectively deprecates |mach gradle-install|. This should improve the robustness of our Gradle configuration, ensuring that we always have projects to import. Since settings.gradle executes very early in the IDE import project sequence: before Gradle project evaluation time, and thus before any Gradle task is executed, we should always see a complete project. (It was possible to see incomplete Gradle configurations if |mach gradle-install| hadn't been run at just the right time.)
build.gradle
mobile/android/base/AndroidManifest.xml
mobile/android/base/build.gradle
mobile/android/base/lint.xml
mobile/android/tests/background/junit4/resources/robolectric.properties
settings.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -110,17 +110,16 @@ idea {
             .findAll({it.startsWith('obj') && !it.startsWith('.') && !it.equals('mobile/')}))
 
         // If topobjdir is below topsrcdir, hide only some portions of that tree.
         def topobjdirURI = file(topobjdir).toURI()
         if (!topsrcdirURI.relativize(topobjdirURI).isAbsolute()) {
             excludeDirs -= file(topobjdir)
             excludeDirs += files(file(topobjdir).listFiles())
             excludeDirs -= file("${topobjdir}/gradle")
-            excludeDirs -= file("${topobjdir}/mobile")
         }
 
         if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {
             excludeDirs += file("${topsrcdir}/mobile/android/thirdparty/com/adjust")
         }
     }
 }
 
copy from mobile/android/gradle/base/AndroidManifest.xml
copy to mobile/android/base/AndroidManifest.xml
--- a/mobile/android/gradle/base/AndroidManifest.xml
+++ b/mobile/android/base/AndroidManifest.xml
@@ -1,4 +1,6 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.mozilla.gecko">
+<!-- THIS IS NOT THE REAL MANIFEST!  This is for Gradle only.  See
+     AndroidManifest.xml.in. -->
 
 </manifest>
copy from mobile/android/gradle/base/build.gradle
copy to mobile/android/base/build.gradle
--- a/mobile/android/gradle/base/build.gradle
+++ b/mobile/android/base/build.gradle
@@ -1,8 +1,10 @@
+buildDir "${topobjdir}/gradle/build/mobile/android/base"
+
 apply plugin: 'com.android.library'
 
 android {
     compileSdkVersion 23
     buildToolsVersion "23.0.1"
 
     defaultConfig {
         targetSdkVersion 22
@@ -13,75 +15,77 @@ android {
         sourceCompatibility JavaVersion.VERSION_1_7
         targetCompatibility JavaVersion.VERSION_1_7
     }
 
     lintOptions {
         abortOnError false
     }
 
-    buildTypes {
-        release {
-            minifyEnabled false
-            proguardFile getDefaultProguardFile('proguard-android.txt')
-        }
-    }
-
     sourceSets {
         main {
+            manifest.srcFile 'AndroidManifest.xml'
             java {
+                srcDir "${topobjdir}/gradle/base/src"
                 exclude 'org/mozilla/gecko/resources/**'
 
+                srcDir "${topsrcdir}/mobile/android/search/java"
+                srcDir "${topsrcdir}/mobile/android/javaaddons/java"
+
+                if (mozconfig.substs.MOZ_ANDROID_MLS_STUMBLER) {
+                    srcDir "${topsrcdir}/mobile/android/stumbler/java"
+                }
+
                 if (!mozconfig.substs.MOZ_CRASHREPORTER) {
                     exclude 'org/mozilla/gecko/CrashReporter.java'
                 }
 
                 if (!mozconfig.substs.MOZ_NATIVE_DEVICES) {
                     exclude 'org/mozilla/gecko/ChromeCast.java'
                     exclude 'org/mozilla/gecko/GeckoMediaPlayer.java'
                     exclude 'org/mozilla/gecko/MediaPlayerManager.java'
                 }
 
                 if (mozconfig.substs.MOZ_WEBRTC) {
-                    srcDir 'src/webrtc_audio_device'
-                    srcDir 'src/webrtc_video_capture'
-                    srcDir 'src/webrtc_video_render'
+                    srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src"
+                    srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src"
+                    srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/modules/video_render/android/java/src"
                 }
 
                 if (mozconfig.substs.MOZ_INSTALL_TRACKING) {
                     exclude 'org/mozilla/gecko/adjust/StubAdjustHelper.java'
                 } else {
                     exclude 'org/mozilla/gecko/adjust/AdjustHelper.java'
                 }
 
                 srcDir "${project.buildDir}/generated/source/preprocessed_code" // See syncPreprocessedCode.
             }
 
             res {
-                srcDir "src/branding/res"
+                srcDir "${topsrcdir}/${mozconfig.substs.MOZ_BRANDING_DIRECTORY}/res"
                 srcDir "${project.buildDir}/generated/source/preprocessed_resources" // See syncPreprocessedResources.
+                srcDir 'resources'
                 if (mozconfig.substs.MOZ_CRASHREPORTER) {
-                    srcDir "src/crashreporter/res"
+                    srcDir 'crashreporter/res'
                 }
             }
         }
 
         test {
             java {
-                srcDir "src/background_junit4"
+                srcDir "${topsrcdir}/mobile/android/tests/browser/junit4/src"
             }
 
             resources {
-                srcDir "resources/background_junit4"
+                srcDir "${topsrcdir}/mobile/android/tests/browser/junit4/resources"
             }
         }
     }
 }
 
-
 task syncPreprocessedCode(type: Sync, dependsOn: rootProject.generateCodeAndResources) {
     into("${project.buildDir}/generated/source/preprocessed_code")
     from("${topobjdir}/mobile/android/base/generated/preprocessed")
 }
 
 task syncPreprocessedResources(type: Sync, dependsOn: rootProject.generateCodeAndResources) {
     into("${project.buildDir}/generated/source/preprocessed_resources")
     from("${topobjdir}/mobile/android/base/res")
@@ -117,11 +121,11 @@ dependencies {
     testCompile 'org.robolectric:robolectric:3.0'
     testCompile 'org.simpleframework:simple-http:4.1.13'
 }
 
 apply plugin: 'idea'
 
 idea {
     module {
-        excludeDirs += file('org/mozilla/gecko/resources')
+        excludeDirs += file("${topobjdir}/gradle/base/src/org/mozilla/gecko/resources")
     }
 }
copy from mobile/android/gradle/base/lint.xml
copy to mobile/android/base/lint.xml
--- a/mobile/android/tests/background/junit4/resources/robolectric.properties
+++ b/mobile/android/tests/background/junit4/resources/robolectric.properties
@@ -1,2 +1,2 @@
-sdk=21
+sdk=22
 constants=org.mozilla.gecko.BuildConfig
--- a/settings.gradle
+++ b/settings.gradle
@@ -16,24 +16,42 @@ if (proc.exitValue() != 0) {
 import groovy.json.JsonSlurper
 def slurper = new JsonSlurper()
 def json = slurper.parseText(standardOutput.toString())
 
 if (json.substs.MOZ_BUILD_APP != 'mobile/android') {
     throw new GradleException("Building with Gradle is only supported for Fennec, i.e., MOZ_BUILD_APP == 'mobile/android'.");
 }
 
+def srcdir = { dst, src ->
+    def d = java.nio.file.Paths.get("${json.topobjdir}/gradle/${dst}")
+    def s = java.nio.file.Paths.get("${json.topsrcdir}/${src}")
+    try {
+        java.nio.file.Files.createDirectories(d.getParent())
+    } catch (java.nio.file.FileAlreadyExistsException e) {
+        // Do nothing.
+    }
+    try {
+        java.nio.file.Files.createSymbolicLink(d, s)
+    } catch (java.nio.file.FileAlreadyExistsException e) {
+        // Do nothing.
+    }
+}
+
+// Since base/ doesn't have the correct package prefix directory structure, we
+// still need to symlink.
+srcdir('base/src/org/mozilla/gecko', 'mobile/android/base')
+
 include ':app'
 include ':base'
 include ':omnijar'
 include ':thirdparty'
 
-def gradleRoot = new File("${json.topobjdir}/mobile/android/gradle")
 project(':app').projectDir = new File("${json.topsrcdir}/mobile/android/app")
-project(':base').projectDir = new File(gradleRoot, 'base')
+project(':base').projectDir = new File("${json.topsrcdir}/mobile/android/base")
 project(':omnijar').projectDir = new File("${json.topsrcdir}/mobile/android/app/omnijar")
 project(':thirdparty').projectDir = new File("${json.topsrcdir}/mobile/android/thirdparty")
 
 // 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