Bug 1845715 - Check for failure when getting RegExp match result template r=iain
[gecko.git] / settings.gradle
blobfde8f41ea3c89f488e4d5685d047f7d976b8a5a9
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 apply from: "${topsrcdir}/mobile/android/gradle/mach_env.gradle"
7 def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
8 if (System.env.GRADLE_MACH_PYTHON) {
9     commandLine.addAll(0, [System.env.GRADLE_MACH_PYTHON])
12 def proc = commandLine.execute(machEnv(topsrcdir), new File(topsrcdir))
13 def standardOutput = new ByteArrayOutputStream()
14 def standardError = new ByteArrayOutputStream()
15 proc.consumeProcessOutput(standardOutput, standardError)
16 proc.waitFor()
18 // Only show the output if something went wrong.
19 if (proc.exitValue() != 0) {
20     logger.info("Error running ./mach environment: \n\n"
21         + "Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n"
22         + "stdout:\n"
23         + "${standardOutput.toString()}\n\n"
24         + "stderr:\n"
25         + "${standardError.toString()}")
26     throw new StopExecutionException(
27             "Could not run ./mach environment. Try running ./mach build first.")
30 import groovy.json.JsonSlurper
32 def slurper = new JsonSlurper()
33 def json = slurper.parseText(standardOutput.toString())
35 if (json.substs.MOZ_BUILD_APP != 'mobile/android') {
36     throw new GradleException("Building with Gradle is only supported for Fennec, i.e., MOZ_BUILD_APP == 'mobile/android'.")
39 // Set the Android SDK location.  This is the *least specific* mechanism, which
40 // is unfortunate: we'd prefer to use the *most specific* mechanism.  That is,
41 // local.properties (first 'sdk.dir', then 'android.dir') and then the
42 // environment variable ANDROID_HOME will override this.  That's unfortunate,
43 // but it's hard to automatically arrange better.
44 System.setProperty('android.home', json.substs.ANDROID_SDK_ROOT)
46 include ':annotations', ':messaging_example', ':port_messaging_example'
47 include ':geckoview'
48 include ':geckoview_example'
49 include ':test_runner'
50 include ':exoplayer2'
52 project(':annotations').projectDir = new File("${json.topsrcdir}/mobile/android/annotations")
53 project(':geckoview').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview")
54 project(':geckoview_example').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview_example")
55 project(':test_runner').projectDir = new File("${json.topsrcdir}/mobile/android/test_runner")
56 project(':exoplayer2').projectDir = new File("${json.topsrcdir}/mobile/android/exoplayer2")
58 if (hasProperty("androidFormatLintTest")) {
59     include ':androidFormatLintTest'
60     project(':androidFormatLintTest').projectDir = new File("${json.topsrcdir}/tools/lint/test/files/android-format")
63 // The Gradle instance is shared between settings.gradle and all the
64 // other build.gradle files (see
65 // http://forums.gradle.org/gradle/topics/define_extension_properties_from_settings_xml).
66 // We use this ext property to pass the per-object-directory mozconfig
67 // between scripts.  This lets us execute set-up code before we gradle
68 // tries to configure the project even once, and as a side benefit
69 // saves invoking |mach environment| multiple times.
70 gradle.ext.mozconfig = json
72 // Produced by `mach build`.  Bug 1543982: the mozconfig determined by `mach
73 // environment` above can be different because `mach build` itself sets certain
74 // critical environment variables including MOZ_OBJDIR, CC, and CXX.  We use
75 // this record to patch up the environment when we recursively invoke `mach
76 // build ...` commands from within Gradle.  This avoids invalidating configure
77 // based on the changed environment variables.
78 def orig = slurper.parse(new File(json.topobjdir, '.mozconfig.json'))
79 gradle.ext.mozconfig.orig_mozconfig = orig.mozconfig
80 project(':messaging_example').projectDir = new File('mobile/android/examples/messaging_example/app')
81 project(':port_messaging_example').projectDir = new File('mobile/android/examples/port_messaging_example/app')