author Nick Alexander <>
Mon, 22 Dec 2014 19:49:04 -0800
changeset 220976 6d4ab59f9764de7a00e9a22074d909994d3cd34a
parent 217666 a26cfc08f359c0417602eb6a207e1f9d80e6688e
child 223856 c5cd6994ee41900bd7259e07ee45613e24d888da
permissions -rw-r--r--
Bug 1098239 - Rewrite mobile/android Gradle integration. r=me This is a big patch, but it's essentially NPOTB. The part that is POTB is ... removing Gradle integration from the build. I've implemented |mach gradle-install| as a substitute for the build system stuff; it's just so much easier to iterate on a mach command than a and I'm landing this with self-review because this lessens the impact of the Gradle integration on the build system and because I am the only person who understands either the old or the new system. You'll need to run |mach gradle-install| at top level to configure the new Gradle integration. But |mach gradle ...| does the right thing configuration steps too. This patch rewrites most of the Gradle integration. The major changes are: * all .gradle files move into mobile/android/gradle; * all the Gradle projects live in the object directory; * mozconfig exposed to all build.gradle files; * simplification of Android configuration between build.gradle files; * support for user-specified version of build tools; * first steps towards supporting builds from the source directory; * bumps Gradle to 2.2.1; * bumps the Android-Gradle plugin to 0.14.4. This is seemingly a step backwards given that we'd prefer to ship the .idea directory in the source directory. But in fact we get closer to that; it's possible to run ./gradlew in the source directory and get a reasonable build. We'll progress with this in time. The win right now is that the projects are nested, which makes importing work better on Linux machines. Unfortunately IntelliJ 13 and 14 now have conflicting Android-Gradle plugin version requirements, so we now only support IntelliJ 14.0.2 and above.

apply plugin: 'java'

// sourceSets {
//     main {
//         java {
//             // Remove the default directories entirely.
//             srcDirs = []
//             // Depend on everything in mobile/android that goes into
//             // the omnijar.
//             srcDir 'src/main/java/locales'
//             srcDir 'src/main/java/chrome'
//             srcDir 'src/main/java/components'
//             srcDir 'src/main/java/modules'
//             srcDir 'src/main/java/themes'
//         }
//     }
// }

 * This task runs when any input file is newer than the omnijar.
task rebuildOmnijar(type:Exec) {
    // Depend on all the inputs labeled as Java sources.
    // { srcDir ->
    //     inputs.sourceDir srcDir
    // }

    inputs.sourceDir 'src/main/java/locales'
    inputs.sourceDir 'src/main/java/chrome'
    inputs.sourceDir 'src/main/java/components'
    inputs.sourceDir 'src/main/java/modules'
    inputs.sourceDir 'src/main/java/themes'

    // Produce a single output file.
    outputs.file "${topobjdir}/dist/fennec/assets/omni.ja"

    workingDir "${topobjdir}"

    commandLine "${topsrcdir}/mach"
    args 'build'
    args '-C'
    args 'mobile/android/base'
    args 'gradle-omnijar'

// Rebuild the omnijar before the earliest Java task.
tasks.compileJava.dependsOn rebuildOmnijar

apply plugin: 'idea'

idea {
    module {