2019-03-15 23:00:45 +03: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
|
2023-01-12 23:45:35 +03:00
|
|
|
|
|
|
|
includeBuild('tools/nimbus-gradle-plugin') {
|
|
|
|
dependencySubstitution {
|
|
|
|
substitute module("org.mozilla.appservices:tooling-nimbus-gradle") using(project(':'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-15 23:00:45 +03:00
|
|
|
buildscript {
|
|
|
|
dependencies {
|
2024-02-18 23:43:52 +03:00
|
|
|
classpath 'org.yaml:snakeyaml:2.2'
|
2019-03-15 23:00:45 +03:00
|
|
|
}
|
|
|
|
repositories {
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
}
|
2023-01-12 23:45:35 +03:00
|
|
|
|
2019-06-13 09:03:51 +03:00
|
|
|
rootProject.name = "appservices"
|
2019-03-15 23:00:45 +03:00
|
|
|
|
|
|
|
def setupProject(name, projectProps) {
|
|
|
|
def path = projectProps.path
|
|
|
|
def description = projectProps.description
|
|
|
|
def artifactId = projectProps.artifactId
|
|
|
|
|
2019-06-11 22:46:43 +03:00
|
|
|
// TODO: Can we remove artifactId?
|
|
|
|
if (name != artifactId) {
|
2019-07-09 23:24:02 +03:00
|
|
|
throw new GradleException("Project name should match artifactId: $name != $artifactId")
|
2019-06-11 22:46:43 +03:00
|
|
|
}
|
|
|
|
|
2019-03-15 23:00:45 +03:00
|
|
|
settings.include(":$name")
|
2018-09-18 00:52:07 +03:00
|
|
|
|
2019-03-15 23:00:45 +03:00
|
|
|
project(":$name").projectDir = new File(rootDir, path)
|
2018-11-09 00:00:56 +03:00
|
|
|
|
2019-03-15 23:00:45 +03:00
|
|
|
// 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
|
|
|
|
project.ext.artifactId = artifactId
|
2019-06-11 22:46:43 +03:00
|
|
|
// Expose the rest of the project properties, mostly for validation reasons.
|
|
|
|
project.ext.configProps = projectProps
|
2019-03-15 23:00:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-09 00:00:56 +03:00
|
|
|
|
2019-03-15 23:00:45 +03:00
|
|
|
def yaml = new Yaml()
|
|
|
|
def buildconfig = yaml.load(new File(rootDir, '.buildconfig-android.yml').newInputStream())
|
|
|
|
buildconfig.projects.each { project ->
|
|
|
|
setupProject(project.key, project.value)
|
|
|
|
}
|
2019-01-30 22:08:53 +03:00
|
|
|
|
2021-12-21 23:47:34 +03:00
|
|
|
Properties localProperties = new Properties();
|
|
|
|
if (file('local.properties').canRead()) {
|
|
|
|
localProperties.load(file('local.properties').newDataInputStream())
|
|
|
|
localProperties.each { prop ->
|
|
|
|
gradle.ext.set("localProperties.${prop.key}", prop.value)
|
|
|
|
}
|
|
|
|
logger.lifecycle('Local configuration: loaded local.properties')
|
|
|
|
} else {
|
|
|
|
logger.lifecycle('Local configuration: absent local.properties; proceeding as normal.')
|
|
|
|
}
|
|
|
|
|
|
|
|
def calcVersion(buildconfig) {
|
|
|
|
def local = gradle.rootProject.findProperty("local")
|
2023-07-13 19:22:55 +03:00
|
|
|
def version = new File(rootDir, 'version.txt').getText().trim()
|
2023-02-24 23:40:43 +03:00
|
|
|
|
|
|
|
if (gradle.rootProject.hasProperty("nightlyVersion")) {
|
|
|
|
return gradle.rootProject.nightlyVersion
|
2021-12-21 23:47:34 +03:00
|
|
|
} else if(local) {
|
|
|
|
return '0.0.1-SNAPSHOT'
|
|
|
|
} else {
|
2023-07-13 19:22:55 +03:00
|
|
|
return version
|
2021-12-21 23:47:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-10 20:05:47 +03:00
|
|
|
def calcGroupId(buildconfig) {
|
|
|
|
if (gradle.rootProject.hasProperty("nightlyVersion")) {
|
|
|
|
return buildconfig.groupId + ".nightly"
|
|
|
|
} else {
|
|
|
|
return buildconfig.groupId
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-15 23:00:45 +03:00
|
|
|
gradle.projectsLoaded { ->
|
|
|
|
// 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.library = [
|
2020-02-24 05:10:50 +03:00
|
|
|
// You can use -Plocal=true to help with mavenLocal publishing workflow.
|
|
|
|
// It makes a fake version number that's smaller than any published version,
|
|
|
|
// which can be depended on specifically by the ./build-scripts/substitute-local-appservices.gradle
|
|
|
|
// but which is unlikely to be depended on by accident otherwise.
|
2021-12-21 23:47:34 +03:00
|
|
|
version: calcVersion(buildconfig),
|
2023-03-10 20:05:47 +03:00
|
|
|
groupId: calcGroupId(buildconfig),
|
2019-03-15 23:00:45 +03:00
|
|
|
]
|
|
|
|
}
|