|
Packit |
f0b94e |
// You might think topsrcdir is '.', but that's not true when the Gradle build
|
|
Packit |
f0b94e |
// is launched from within IntelliJ.
|
|
Packit |
f0b94e |
def topsrcdir = rootProject.projectDir.absolutePath
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
|
|
Packit |
f0b94e |
def proc = commandLine.execute(null, new File(topsrcdir))
|
|
Packit |
f0b94e |
def standardOutput = new ByteArrayOutputStream()
|
|
Packit |
f0b94e |
proc.consumeProcessOutput(standardOutput, standardOutput)
|
|
Packit |
f0b94e |
proc.waitFor()
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// Only show the output if something went wrong.
|
|
Packit |
f0b94e |
if (proc.exitValue() != 0) {
|
|
Packit |
f0b94e |
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n${standardOutput.toString()}")
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
import groovy.json.JsonSlurper
|
|
Packit |
f0b94e |
def slurper = new JsonSlurper()
|
|
Packit |
f0b94e |
def json = slurper.parseText(standardOutput.toString())
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
if (json.substs.MOZ_BUILD_APP != 'mobile/android') {
|
|
Packit |
f0b94e |
throw new GradleException("Building with Gradle is only supported for Fennec, i.e., MOZ_BUILD_APP == 'mobile/android'.")
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// Set the Android SDK location. This is the *least specific* mechanism, which
|
|
Packit |
f0b94e |
// is unfortunate: we'd prefer to use the *most specific* mechanism. That is,
|
|
Packit |
f0b94e |
// local.properties (first 'sdk.dir', then 'android.dir') and then the
|
|
Packit |
f0b94e |
// environment variable ANDROID_HOME will override this. That's unfortunate,
|
|
Packit |
f0b94e |
// but it's hard to automatically arrange better.
|
|
Packit |
f0b94e |
System.setProperty('android.home', json.substs.ANDROID_SDK_ROOT)
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
include ':app'
|
|
Packit |
f0b94e |
include ':geckoview'
|
|
Packit |
f0b94e |
include ':geckoview_example'
|
|
Packit |
f0b94e |
include ':omnijar'
|
|
Packit |
f0b94e |
include ':thirdparty'
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
project(':app').projectDir = new File("${json.topsrcdir}/mobile/android/app")
|
|
Packit |
f0b94e |
project(':geckoview').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview")
|
|
Packit |
f0b94e |
project(':geckoview_example').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview_example")
|
|
Packit |
f0b94e |
project(':omnijar').projectDir = new File("${json.topsrcdir}/mobile/android/app/omnijar")
|
|
Packit |
f0b94e |
project(':thirdparty').projectDir = new File("${json.topsrcdir}/mobile/android/thirdparty")
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// The Gradle instance is shared between settings.gradle and all the
|
|
Packit |
f0b94e |
// other build.gradle files (see
|
|
Packit |
f0b94e |
// http://forums.gradle.org/gradle/topics/define_extension_properties_from_settings_xml).
|
|
Packit |
f0b94e |
// We use this ext property to pass the per-object-directory mozconfig
|
|
Packit |
f0b94e |
// between scripts. This lets us execute set-up code before we gradle
|
|
Packit |
f0b94e |
// tries to configure the project even once, and as a side benefit
|
|
Packit |
f0b94e |
// saves invoking |mach environment| multiple times.
|
|
Packit |
f0b94e |
gradle.ext.mozconfig = json
|