Bug 1832850 - Part 3: Remove an unnecessary include and some unnecessary forward...
[gecko.git] / settings.gradle
blob377bb55c690d398f22bdf68f417f48c77d953028
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.properties['os.name'].toLowerCase().contains('windows')) {
9     // gradle is called before parsing config.status, we cannot use PYTHON
10     // value.
11     if (System.env.MOZILLABUILD) {
12         def mozillabuild = System.env.MOZILLABUILD.toLowerCase()
13         if (mozillabuild) {
14             commandLine.addAll(0, ["${mozillabuild}/python3/python3.exe"])
15         }
16     }
19 def proc = commandLine.execute(machEnv(topsrcdir), new File(topsrcdir))
20 def standardOutput = new ByteArrayOutputStream()
21 def standardError = new ByteArrayOutputStream()
22 proc.consumeProcessOutput(standardOutput, standardError)
23 proc.waitFor()
25 // Only show the output if something went wrong.
26 if (proc.exitValue() != 0) {
27     logger.info("Error running ./mach environment: \n\n"
28         + "Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n"
29         + "stdout:\n"
30         + "${standardOutput.toString()}\n\n"
31         + "stderr:\n"
32         + "${standardError.toString()}")
33     throw new StopExecutionException(
34             "Could not run ./mach environment. Try running ./mach build first.")
37 import groovy.json.JsonSlurper
39 def slurper = new JsonSlurper()
40 def json = slurper.parseText(standardOutput.toString())
42 if (json.substs.MOZ_BUILD_APP != 'mobile/android') {
43     throw new GradleException("Building with Gradle is only supported for Fennec, i.e., MOZ_BUILD_APP == 'mobile/android'.")
46 // Set the Android SDK location.  This is the *least specific* mechanism, which
47 // is unfortunate: we'd prefer to use the *most specific* mechanism.  That is,
48 // local.properties (first 'sdk.dir', then 'android.dir') and then the
49 // environment variable ANDROID_HOME will override this.  That's unfortunate,
50 // but it's hard to automatically arrange better.
51 System.setProperty('android.home', json.substs.ANDROID_SDK_ROOT)
53 include ':annotations', ':messaging_example', ':port_messaging_example'
54 include ':geckoview'
55 include ':geckoview_example'
56 include ':test_runner'
57 include ':exoplayer2'
59 project(':annotations').projectDir = new File("${json.topsrcdir}/mobile/android/annotations")
60 project(':geckoview').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview")
61 project(':geckoview_example').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview_example")
62 project(':test_runner').projectDir = new File("${json.topsrcdir}/mobile/android/test_runner")
63 project(':exoplayer2').projectDir = new File("${json.topsrcdir}/mobile/android/exoplayer2")
65 if (hasProperty("androidFormatLintTest")) {
66     include ':androidFormatLintTest'
67     project(':androidFormatLintTest').projectDir = new File("${json.topsrcdir}/tools/lint/test/files/android-format")
70 // The Gradle instance is shared between settings.gradle and all the
71 // other build.gradle files (see
72 // http://forums.gradle.org/gradle/topics/define_extension_properties_from_settings_xml).
73 // We use this ext property to pass the per-object-directory mozconfig
74 // between scripts.  This lets us execute set-up code before we gradle
75 // tries to configure the project even once, and as a side benefit
76 // saves invoking |mach environment| multiple times.
77 gradle.ext.mozconfig = json
79 // Produced by `mach build`.  Bug 1543982: the mozconfig determined by `mach
80 // environment` above can be different because `mach build` itself sets certain
81 // critical environment variables including MOZ_OBJDIR, CC, and CXX.  We use
82 // this record to patch up the environment when we recursively invoke `mach
83 // build ...` commands from within Gradle.  This avoids invalidating configure
84 // based on the changed environment variables.
85 def orig = slurper.parse(new File(json.topobjdir, '.mozconfig.json'))
86 gradle.ext.mozconfig.orig_mozconfig = orig.mozconfig
87 project(':messaging_example').projectDir = new File('mobile/android/examples/messaging_example/app')
88 project(':port_messaging_example').projectDir = new File('mobile/android/examples/port_messaging_example/app')