Bug 1842694 - Refactor GithubDetailsTask into a plugin using composite build
[gecko.git] / mobile / android / fenix / settings.gradle
blobdd6a86e2a33fdebc4a3c3bc048b3f84d965a4e56
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 pluginManagement {
6     includeBuild("../android-components/plugins/publicsuffixlist")
7     includeBuild("../android-components/plugins/dependencies")
8     includeBuild("../android-components/plugins/config")
9     includeBuild("../android-components/plugins/github")
10     includeBuild("./plugins/apksize")
11     includeBuild("./plugins/fenixdependencies")
14 plugins {
15     id 'ApkSizePlugin'
16     id 'FenixDependenciesPlugin'
17     id "mozac.ConfigPlugin"
18     id 'mozac.DependenciesPlugin'
19     id 'mozac.GitHubPlugin'
22 apply from: file('../shared-settings.gradle')
24 include ':app'
25 include ':mozilla-detekt-rules'
26 include ':mozilla-lint-rules'
27 include ':benchmark'
29 gradle.projectsLoaded { ->
30     // Disables A-C tests and lint when building Fenix.
31     gradle.allprojects { project ->
32         if (project.projectDir.absolutePath.contains("/android-components/")) {
33             project.tasks.withType(Test) {
34                 enabled = false
35             }
36             project.tasks.whenTaskAdded { task ->
37                 if (task.name.contains("lint")) {
38                     task.enabled = false
39                 }
40             }
41         }
43         def appServicesSrcDir = null
44         if (gradle.hasProperty('localProperties.autoPublish.application-services.dir')) {
45           appServicesSrcDir = gradle.getProperty('localProperties.autoPublish.application-services.dir')
46         } else if (gradle.hasProperty('localProperties.branchBuild.application-services.dir')) {
47           appServicesSrcDir = gradle.getProperty('localProperties.branchBuild.application-services.dir')
48         }
49         if (appServicesSrcDir) {
50             if (appServicesSrcDir.startsWith("/")) {
51                 apply from: "${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle"
52             } else {
53                 apply from: "${rootProject.projectDir}/${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle"
54             }
55         }
56     }
59 def log(message) {
60     logger.lifecycle("[settings] ${message}")
63 def runCmd(cmd, workingDir, successMessage, captureStdout=true) {
64     def proc = cmd.execute(null, new File(workingDir))
65     def standardOutput = captureStdout ? new ByteArrayOutputStream() : System.out
66     proc.consumeProcessOutput(standardOutput, System.err)
67     proc.waitFor()
69     if (proc.exitValue() != 0) {
70         throw new GradleException("Process '${cmd}' finished with non-zero exit value ${proc.exitValue()}");
71     } else {
72         log(successMessage)
73     }
74     return captureStdout ? standardOutput : null
77 //////////////////////////////////////////////////////////////////////////
78 // Local Development overrides
79 //////////////////////////////////////////////////////////////////////////
81 Properties localProperties = null
82 String settingAppServicesPath = "autoPublish.application-services.dir"
83 String settingGleanPath = "autoPublish.glean.dir"
85 if (file('local.properties').canRead()) {
86     localProperties = new Properties()
87     localProperties.load(file('local.properties').newDataInputStream())
88     log('Loaded local.properties')
89 } else {
90     log('Missing local.properties; see https://github.com/mozilla-mobile/fenix/blob/main/README.md#local-properties-helpers for instructions.')
93 if (localProperties != null) {
94     localProperties.each { prop ->
95         gradle.ext.set("localProperties.${prop.key}", prop.value)
96     }
98     String appServicesLocalPath = localProperties.getProperty(settingAppServicesPath)
100     if (appServicesLocalPath != null) {
101         log("Enabling automatic publication of application-services from: $appServicesLocalPath")
102         // Windows can't execute .py files directly, so we assume a "manually installed" python,
103         // which comes with a "py" launcher and respects the shebang line to specify the version.
104         def publishAppServicesCmd = [];
105         if (System.properties['os.name'].toLowerCase().contains('windows')) {
106             publishAppServicesCmd << "py";
107         }
108         publishAppServicesCmd << "./automation/publish_to_maven_local_if_modified.py";
109         runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.", false)
110     } else {
111         log("Disabled auto-publication of application-services. Enable it by settings '$settingAppServicesPath' in local.properties")
112     }
114     String gleanLocalPath = localProperties.getProperty(settingGleanPath)
116     if (gleanLocalPath != null) {
117         log("Enabling automatic publication of Glean from: $gleanLocalPath")
118         // As above, hacks to execute .py files on Windows.
119         def publishGleanCmd = [];
120         if (System.properties['os.name'].toLowerCase().contains('windows')) {
121             publishGleanCmd << "py";
122         }
123         publishGleanCmd << "./build-scripts/publish_to_maven_local_if_modified.py";
124         runCmd(publishGleanCmd, gleanLocalPath, "Published Glean for local development.", false)
125     } else {
126         log("Disabled auto-publication of Glean. Enable it by settings '$settingGleanPath' in local.properties")
127     }