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/. */
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")
16 id 'FenixDependenciesPlugin'
17 id "mozac.ConfigPlugin"
18 id 'mozac.DependenciesPlugin'
19 id 'mozac.GitHubPlugin'
22 apply from: file('../shared-settings.gradle')
25 include ':mozilla-detekt-rules'
26 include ':mozilla-lint-rules'
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) {
36 project.tasks.whenTaskAdded { task ->
37 if (task.name.contains("lint")) {
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')
49 if (appServicesSrcDir) {
50 if (appServicesSrcDir.startsWith("/")) {
51 apply from: "${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle"
53 apply from: "${rootProject.projectDir}/${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle"
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)
69 if (proc.exitValue() != 0) {
70 throw new GradleException("Process '${cmd}' finished with non-zero exit value ${proc.exitValue()}");
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')
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)
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";
108 publishAppServicesCmd << "./automation/publish_to_maven_local_if_modified.py";
109 runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.", false)
111 log("Disabled auto-publication of application-services. Enable it by settings '$settingAppServicesPath' in local.properties")
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";
123 publishGleanCmd << "./build-scripts/publish_to_maven_local_if_modified.py";
124 runCmd(publishGleanCmd, gleanLocalPath, "Published Glean for local development.", false)
126 log("Disabled auto-publication of Glean. Enable it by settings '$settingGleanPath' in local.properties")