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/focusdependencies")
14 id "mozac.ConfigPlugin"
15 id 'mozac.DependenciesPlugin'
16 id 'mozac.GitHubPlugin'
17 id 'FocusDependenciesPlugin'
20 apply from: file('../shared-settings.gradle')
23 include ':service-telemetry'
25 gradle.projectsLoaded { ->
26 // Disables A-C tests and lint when building Focus.
27 gradle.allprojects { project ->
28 if (project.projectDir.absolutePath.contains("/android-components/")) {
29 project.tasks.withType(Test) {
32 project.tasks.whenTaskAdded { task ->
33 if (task.name.contains("lint")) {
39 def appServicesSrcDir = null
40 if (gradle.hasProperty('localProperties.autoPublish.application-services.dir')) {
41 appServicesSrcDir = gradle.getProperty('localProperties.autoPublish.application-services.dir')
42 } else if (gradle.hasProperty('localProperties.branchBuild.application-services.dir')) {
43 appServicesSrcDir = gradle.getProperty('localProperties.branchBuild.application-services.dir')
45 if (appServicesSrcDir) {
46 if (appServicesSrcDir.startsWith("/")) {
47 apply from: "${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle"
49 apply from: "${rootProject.projectDir}/${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle"
56 logger.lifecycle("[settings] ${message}")
59 def runCmd(cmd, workingDir, successMessage, captureStdout=true) {
60 def proc = cmd.execute(null, new File(workingDir))
61 def standardOutput = captureStdout ? new ByteArrayOutputStream() : System.out
62 proc.consumeProcessOutput(standardOutput, System.err)
65 if (proc.exitValue() != 0) {
66 throw new GradleException("Process '${cmd}' finished with non-zero exit value ${proc.exitValue()}");
70 return captureStdout ? standardOutput : null
73 //////////////////////////////////////////////////////////////////////////
74 // Local development enhancements
75 //////////////////////////////////////////////////////////////////////////
77 Properties localProperties = null
78 String settingAppServicesPath = "autoPublish.application-services.dir"
79 String settingGleanPath = "autoPublish.glean.dir"
81 if (file('local.properties').canRead()) {
82 localProperties = new Properties()
83 localProperties.load(file('local.properties').newDataInputStream())
84 log('Loaded local.properties')
86 log('Missing local.properties; see https://github.com/mozilla-mobile/focus-android#localproperties-helpers for instructions.')
89 if (localProperties != null) {
90 localProperties.each { prop ->
91 gradle.ext.set("localProperties.${prop.key}", prop.value)
94 String appServicesLocalPath = localProperties.getProperty(settingAppServicesPath)
96 if (appServicesLocalPath != null) {
97 log("Enabling automatic publication of application-services from: $appServicesLocalPath")
98 // Windows can't execute .py files directly, so we assume a "manually installed" python,
99 // which comes with a "py" launcher and respects the shebang line to specify the version.
100 def publishAppServicesCmd = [];
101 if (System.properties['os.name'].toLowerCase().contains('windows')) {
102 publishAppServicesCmd << "py";
104 publishAppServicesCmd << "./automation/publish_to_maven_local_if_modified.py";
105 runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.", false)
107 log("Disabled auto-publication of application-services. Enable it by settings '$settingAppServicesPath' in local.properties")
110 String gleanLocalPath = localProperties.getProperty(settingGleanPath)
112 if (gleanLocalPath != null) {
113 log("Enabling automatic publication of Glean from: $gleanLocalPath")
114 // As above, hacks to execute .py files on Windows.
115 def publishGleanCmd = [];
116 if (System.properties['os.name'].toLowerCase().contains('windows')) {
117 publishGleanCmd << "py";
119 publishGleanCmd << "./build-scripts/publish_to_maven_local_if_modified.py";
120 runCmd(publishGleanCmd, gleanLocalPath, "Published Glean for local development.", false)
122 log("Disabled auto-publication of Glean. Enable it by settings '$settingGleanPath' in local.properties")