2022-12-09 06:31:12 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
import org.yaml.snakeyaml.Yaml
|
|
|
|
|
|
|
|
pluginManagement {
|
|
|
|
includeBuild("../android-components/plugins/publicsuffixlist")
|
|
|
|
includeBuild("../android-components/plugins/dependencies")
|
|
|
|
}
|
|
|
|
|
2019-03-21 19:41:41 +00:00
|
|
|
|
2022-12-09 06:31:12 +00:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
classpath 'org.yaml:snakeyaml:1.33'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id 'mozac.DependenciesPlugin'
|
|
|
|
}
|
|
|
|
|
|
|
|
include ':app'
|
2019-12-31 16:46:22 +00:00
|
|
|
include ':mozilla-detekt-rules'
|
2020-03-03 18:44:54 +00:00
|
|
|
include ':mozilla-lint-rules'
|
2022-12-09 06:31:12 +00:00
|
|
|
|
|
|
|
// Synchronized library configuration for all modules
|
|
|
|
// This "componentsVersion" number is defined in "version.txt" and should follow
|
|
|
|
// semantic versioning (MAJOR.MINOR.PATCH). See https://semver.org/
|
|
|
|
class Config {
|
|
|
|
|
|
|
|
public final String componentsVersion
|
|
|
|
public final String componentsGroupId
|
|
|
|
public final Integer compileSdkVersion
|
|
|
|
public final Integer minSdkVersion
|
|
|
|
public final Integer targetSdkVersion
|
|
|
|
|
|
|
|
Config(
|
|
|
|
String componentsVersion,
|
|
|
|
String componentsGroupId,
|
|
|
|
Integer compileSdkVersion,
|
|
|
|
Integer minSdkVersion,
|
|
|
|
Integer targetSdkVersion
|
|
|
|
) {
|
|
|
|
this.componentsVersion = componentsVersion
|
|
|
|
this.componentsGroupId = componentsGroupId
|
|
|
|
this.compileSdkVersion = compileSdkVersion
|
|
|
|
this.minSdkVersion = minSdkVersion
|
|
|
|
this.targetSdkVersion = targetSdkVersion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def setupProject(name, path, description) {
|
|
|
|
settings.include(":$name")
|
|
|
|
|
|
|
|
project(":$name").projectDir = new File(rootDir, "../android-components/${path}")
|
|
|
|
|
|
|
|
// project(...) gives us a skeleton project that we can't set ext.* on
|
|
|
|
gradle.beforeProject { project ->
|
|
|
|
// However, the "afterProject" listener iterates over every project and gives us the actual project
|
|
|
|
// So, once we filter for the project we care about, we can set whatever we want
|
|
|
|
if (project.name == name) {
|
|
|
|
project.ext.description = description
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def yaml = new Yaml()
|
|
|
|
def buildconfig = yaml.load(new File(rootDir, '../android-components/.buildconfig.yml').newInputStream())
|
|
|
|
|
|
|
|
buildconfig.projects.each { project ->
|
|
|
|
if (!project.key.startsWith("samples")) {
|
|
|
|
setupProject(project.key, project.value.path, project.value.description)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gradle.projectsLoaded { ->
|
|
|
|
def componentsVersion = new File(rootDir, '../version.txt').text.stripTrailing()
|
|
|
|
def configData = yaml.load(new File(rootDir, '../android-components/.config.yml').newInputStream())
|
|
|
|
|
|
|
|
// Wait until root project is "loaded" before we set "config"
|
|
|
|
// Note that since this is set on "rootProject.ext", it will be "in scope" during the evaluation of all projects'
|
|
|
|
// gradle files. This means that they can just access "config.<value>", and it'll function properly
|
|
|
|
gradle.rootProject.ext.config = new Config(
|
|
|
|
componentsVersion,
|
|
|
|
configData.componentsGroupId,
|
|
|
|
configData.compileSdkVersion,
|
|
|
|
configData.minSdkVersion,
|
|
|
|
configData.targetSdkVersion
|
|
|
|
)
|
|
|
|
gradle.rootProject.ext.buildConfig = buildconfig
|
|
|
|
|
|
|
|
// Disables A-C tests and lint when building Fenix.
|
|
|
|
gradle.allprojects { project ->
|
|
|
|
if (project.projectDir.absolutePath.contains("/android-components/")) {
|
|
|
|
project.tasks.withType(Test) {
|
|
|
|
enabled = false
|
|
|
|
}
|
|
|
|
project.tasks.whenTaskAdded { task ->
|
|
|
|
if (task.name.contains("lint")) {
|
|
|
|
task.enabled = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-04 23:01:12 +00:00
|
|
|
def log(message) {
|
|
|
|
logger.lifecycle("[settings] ${message}")
|
|
|
|
}
|
|
|
|
|
2020-02-24 02:20:19 +00:00
|
|
|
def runCmd(cmd, workingDir, successMessage, captureStdout=true) {
|
2019-10-04 23:01:12 +00:00
|
|
|
def proc = cmd.execute(null, new File(workingDir))
|
2020-02-24 02:20:19 +00:00
|
|
|
def standardOutput = captureStdout ? new ByteArrayOutputStream() : System.out
|
|
|
|
proc.consumeProcessOutput(standardOutput, System.err)
|
2019-10-04 23:01:12 +00:00
|
|
|
proc.waitFor()
|
|
|
|
|
|
|
|
if (proc.exitValue() != 0) {
|
2020-02-24 02:20:19 +00:00
|
|
|
throw new GradleException("Process '${cmd}' finished with non-zero exit value ${proc.exitValue()}");
|
2019-10-04 23:01:12 +00:00
|
|
|
} else {
|
|
|
|
log(successMessage)
|
|
|
|
}
|
2020-02-24 02:20:19 +00:00
|
|
|
return captureStdout ? standardOutput : null
|
2019-10-04 23:01:12 +00:00
|
|
|
}
|
|
|
|
|
2019-03-21 19:41:41 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Local Development overrides
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-10-04 23:01:12 +00:00
|
|
|
Properties localProperties = null
|
2020-02-24 02:20:19 +00:00
|
|
|
String settingAppServicesPath = "autoPublish.application-services.dir"
|
2019-10-04 23:01:12 +00:00
|
|
|
String settingAndroidComponentsPath = "autoPublish.android-components.dir"
|
2022-04-21 10:26:27 +00:00
|
|
|
String settingGleanPath = "autoPublish.glean.dir"
|
2019-03-21 19:41:41 +00:00
|
|
|
|
|
|
|
if (file('local.properties').canRead()) {
|
|
|
|
localProperties = new Properties()
|
|
|
|
localProperties.load(file('local.properties').newDataInputStream())
|
2019-10-04 23:01:12 +00:00
|
|
|
log('Loaded local.properties')
|
2019-03-21 19:41:41 +00:00
|
|
|
} else {
|
2021-07-28 12:20:14 +00:00
|
|
|
log('Missing local.properties; see https://github.com/mozilla-mobile/fenix/blob/main/README.md#local-properties-helpers for instructions.')
|
2019-03-21 19:41:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (localProperties != null) {
|
2019-08-15 21:33:40 +00:00
|
|
|
localProperties.each { prop ->
|
|
|
|
gradle.ext.set("localProperties.${prop.key}", prop.value)
|
|
|
|
}
|
|
|
|
|
2019-10-04 23:01:12 +00:00
|
|
|
String appServicesLocalPath = localProperties.getProperty(settingAppServicesPath)
|
2019-03-21 19:41:41 +00:00
|
|
|
|
|
|
|
if (appServicesLocalPath != null) {
|
2020-02-24 02:20:19 +00:00
|
|
|
log("Enabling automatic publication of application-services from: $appServicesLocalPath")
|
2020-07-21 05:21:41 +00:00
|
|
|
// Windows can't execute .py files directly, so we assume a "manually installed" python,
|
|
|
|
// which comes with a "py" launcher and respects the shebang line to specify the version.
|
|
|
|
def publishAppServicesCmd = [];
|
2020-06-12 07:47:45 +00:00
|
|
|
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
2020-07-21 05:21:41 +00:00
|
|
|
publishAppServicesCmd << "py";
|
2020-06-12 07:47:45 +00:00
|
|
|
}
|
2020-07-21 05:21:41 +00:00
|
|
|
publishAppServicesCmd << "./automation/publish_to_maven_local_if_modified.py";
|
|
|
|
runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.", false)
|
2019-03-21 19:41:41 +00:00
|
|
|
} else {
|
2020-02-24 02:20:19 +00:00
|
|
|
log("Disabled auto-publication of application-services. Enable it by settings '$settingAppServicesPath' in local.properties")
|
2019-10-04 23:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String androidComponentsLocalPath = localProperties.getProperty(settingAndroidComponentsPath)
|
|
|
|
|
|
|
|
if (androidComponentsLocalPath != null) {
|
|
|
|
log("Enabling automatic publication of android-components from: $androidComponentsLocalPath")
|
2020-07-21 05:21:41 +00:00
|
|
|
// As above, hacks to execute .py files on Windows.
|
2020-06-12 07:47:45 +00:00
|
|
|
def publishAcCmd = [];
|
|
|
|
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
|
|
|
publishAcCmd << "py";
|
|
|
|
}
|
|
|
|
publishAcCmd << "./automation/publish_to_maven_local_if_modified.py";
|
2020-04-21 22:21:41 +00:00
|
|
|
runCmd(publishAcCmd, androidComponentsLocalPath, "Published android-components for local development.", false)
|
2019-10-04 23:01:12 +00:00
|
|
|
} else {
|
|
|
|
log("Disabled auto-publication of android-components. Enable it by settings '$settingAndroidComponentsPath' in local.properties")
|
2019-03-21 19:41:41 +00:00
|
|
|
}
|
2022-04-21 10:26:27 +00:00
|
|
|
|
|
|
|
String gleanLocalPath = localProperties.getProperty(settingGleanPath)
|
|
|
|
|
|
|
|
if (gleanLocalPath != null) {
|
|
|
|
log("Enabling automatic publication of Glean from: $gleanLocalPath")
|
|
|
|
// As above, hacks to execute .py files on Windows.
|
|
|
|
def publishGleanCmd = [];
|
|
|
|
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
|
|
|
publishGleanCmd << "py";
|
|
|
|
}
|
|
|
|
publishGleanCmd << "./build-scripts/publish_to_maven_local_if_modified.py";
|
|
|
|
runCmd(publishGleanCmd, gleanLocalPath, "Published Glean for local development.", false)
|
|
|
|
} else {
|
|
|
|
log("Disabled auto-publication of Glean. Enable it by settings '$settingGleanPath' in local.properties")
|
|
|
|
}
|
2019-10-04 23:01:12 +00:00
|
|
|
}
|