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.)

--HG--
extra : commitid : 4zK7U5PAypH
extra : rebase_source : 91f8534a89f0311b36bd39f502e2f7609a1d78b0
This commit is contained in:
Nick Alexander 2015-11-03 15:04:39 -08:00
Родитель c7aa6f11f0
Коммит 44046732fb
5 изменённых файлов: 165 добавлений и 3 удалений

Просмотреть файл

@ -115,7 +115,6 @@ idea {
excludeDirs -= file(topobjdir)
excludeDirs += files(file(topobjdir).listFiles())
excludeDirs -= file("${topobjdir}/gradle")
excludeDirs -= file("${topobjdir}/mobile")
}
if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {

Просмотреть файл

@ -0,0 +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>

Просмотреть файл

@ -0,0 +1,131 @@
buildDir "${topobjdir}/gradle/build/mobile/android/base"
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 {
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 "${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 "${topsrcdir}/${mozconfig.substs.MOZ_BRANDING_DIRECTORY}/res"
srcDir "${project.buildDir}/generated/source/preprocessed_resources" // See syncPreprocessedResources.
srcDir 'resources'
if (mozconfig.substs.MOZ_CRASHREPORTER) {
srcDir 'crashreporter/res'
}
}
}
test {
java {
srcDir "${topsrcdir}/mobile/android/tests/background/junit4/src"
}
resources {
srcDir "${topsrcdir}/mobile/android/tests/background/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")
}
android.libraryVariants.all { variant ->
variant.preBuild.dependsOn syncPreprocessedCode
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'
compile 'com.android.support:design:23.0.1'
if (mozconfig.substs.MOZ_NATIVE_DEVICES) {
compile 'com.android.support:mediarouter-v7:23.0.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'
}
if (mozconfig.substs.MOZ_ANDROID_GCM) {
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-gcm:8.1.0'
}
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'
idea {
module {
excludeDirs += file("${topobjdir}/gradle/base/src/org/mozilla/gecko/resources")
}
}

Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Enable relevant checks disabled by default -->
<issue id="NegativeMargin" severity="warning" />
<!-- We have a custom menu and don't conform to the recommended styles. -->
<issue id="IconColors" severity="ignore" />
</lint>

Просмотреть файл

@ -21,14 +21,32 @@ 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")