author Nick Alexander <>
Mon, 19 Oct 2015 18:06:10 -0700
changeset 289267 d12ef59cbae5529866519f80a07138d1f8cc858d
parent 289266 eae251eb922efb66b0fd985f92c8e52f1a16d430
child 289268 27b83dafe62594dfafb630af5e13f9c806137a12
permissions -rw-r--r--
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.

// If our root project is in the object directory, we expect to be given
// topsrcdir from our environment via  If we don't get it,
// our root project is in the source directory, so we extract topsrcdir relative
// to the location of this script.
if (!hasProperty('topsrcdir')) {
    // In the source directory, we're not worried about links crossing directories.
    binding.variables['topsrcdir'] = new File("../../..").getCanonicalPath()
    logger.warn("topsrcdir is undefined: assuming source directory Gradle invocation with topsrcdir=${topsrcdir}.")

def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
def proc = commandLine.execute(null, new File(topsrcdir))
def standardOutput = new ByteArrayOutputStream()
proc.consumeProcessOutput(standardOutput, standardOutput)

// Only show the output if something went wrong.
if (proc.exitValue() != 0) {
    throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n${standardOutput.toString()}")

import groovy.json.JsonSlurper
def slurper = new JsonSlurper()
def json = slurper.parseText(standardOutput.toString())

include ':app'
include ':base'
include ':omnijar'
include ':preprocessed_code'
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(':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
// other build.gradle files (see
// 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