1 // You might think topsrcdir is '.', but that's not true when the Gradle build
2 // is launched from within IntelliJ.
3 def topsrcdir = rootProject.projectDir.absolutePath
5 def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
6 if (System.properties['os.name'].toLowerCase().contains('windows')) {
7 // gradle is called before parsing config.status, we cannot use PYTHON
9 if (System.env.MOZILLABUILD) {
10 def mozillabuild = System.env.MOZILLABUILD
12 commandLine.addAll(0, ["${mozillabuild}/python/python.exe"])
16 def proc = commandLine.execute(null, new File(topsrcdir))
17 def standardOutput = new ByteArrayOutputStream()
18 proc.consumeProcessOutput(standardOutput, standardOutput)
21 // Only show the output if something went wrong.
22 if (proc.exitValue() != 0) {
23 throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n${standardOutput.toString()}")
26 import groovy.json.JsonSlurper
28 def slurper = new JsonSlurper()
29 def json = slurper.parseText(standardOutput.toString())
31 if (json.substs.MOZ_BUILD_APP != 'mobile/android') {
32 throw new GradleException("Building with Gradle is only supported for Fennec, i.e., MOZ_BUILD_APP == 'mobile/android'.")
35 // Set the Android SDK location. This is the *least specific* mechanism, which
36 // is unfortunate: we'd prefer to use the *most specific* mechanism. That is,
37 // local.properties (first 'sdk.dir', then 'android.dir') and then the
38 // environment variable ANDROID_HOME will override this. That's unfortunate,
39 // but it's hard to automatically arrange better.
40 System.setProperty('android.home', json.substs.ANDROID_SDK_ROOT)
42 include ':annotations'
45 include ':geckoview_example'
49 project(':annotations').projectDir = new File("${json.topsrcdir}/mobile/android/annotations")
50 project(':app').projectDir = new File("${json.topsrcdir}/mobile/android/app")
51 project(':geckoview').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview")
52 project(':geckoview_example').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview_example")
53 project(':omnijar').projectDir = new File("${json.topsrcdir}/mobile/android/app/omnijar")
54 project(':thirdparty').projectDir = new File("${json.topsrcdir}/mobile/android/thirdparty")
56 // The Gradle instance is shared between settings.gradle and all the
57 // other build.gradle files (see
58 // http://forums.gradle.org/gradle/topics/define_extension_properties_from_settings_xml).
59 // We use this ext property to pass the per-object-directory mozconfig
60 // between scripts. This lets us execute set-up code before we gradle
61 // tries to configure the project even once, and as a side benefit
62 // saves invoking |mach environment| multiple times.
63 gradle.ext.mozconfig = json