mobile/android/gradle/settings.gradle
author Nick Alexander <nalexander@mozilla.com>
Tue, 20 Oct 2015 17:52:15 -0700
changeset 289588 ef1e7dec5bad489be4556a10344626adefffc38d
parent 289268 27b83dafe62594dfafb630af5e13f9c806137a12
permissions -rw-r--r--
Bug 1174244 - Part 4: Remove 'thirdparty_adjust_sdk' Gradle project. r=sebastian

// If our root project is in the object directory, we expect to be given
// topsrcdir from our environment via gradle.properties.  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)
proc.waitFor()

// 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 ':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(':thirdparty').projectDir = new File(gradleRoot, '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
// tries to configure the project even once, and as a side benefit
// saves invoking |mach environment| multiple times.
gradle.ext.mozconfig = json