-
Notifications
You must be signed in to change notification settings - Fork 227
/
settings.gradle
101 lines (86 loc) · 3.53 KB
/
settings.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* 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
includeBuild('tools/nimbus-gradle-plugin') {
dependencySubstitution {
substitute module("org.mozilla.appservices:tooling-nimbus-gradle") using(project(':'))
}
}
buildscript {
dependencies {
classpath 'org.yaml:snakeyaml:2.2'
}
repositories {
mavenCentral()
}
}
rootProject.name = "appservices"
def setupProject(name, projectProps) {
def path = projectProps.path
def description = projectProps.description
def artifactId = projectProps.artifactId
// TODO: Can we remove artifactId?
if (name != artifactId) {
throw new GradleException("Project name should match artifactId: $name != $artifactId")
}
settings.include(":$name")
project(":$name").projectDir = new File(rootDir, 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
project.ext.artifactId = artifactId
// Expose the rest of the project properties, mostly for validation reasons.
project.ext.configProps = projectProps
}
}
}
def yaml = new Yaml()
def buildconfig = yaml.load(new File(rootDir, '.buildconfig-android.yml').newInputStream())
buildconfig.projects.each { project ->
setupProject(project.key, project.value)
}
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")
def version = new File(rootDir, 'version.txt').getText().trim()
if (gradle.rootProject.hasProperty("nightlyVersion")) {
return gradle.rootProject.nightlyVersion
} else if(local) {
return '0.0.1-SNAPSHOT'
} else {
return version
}
}
def calcGroupId(buildconfig) {
if (gradle.rootProject.hasProperty("nightlyVersion")) {
return buildconfig.groupId + ".nightly"
} else {
return buildconfig.groupId
}
}
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 = [
// 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.
version: calcVersion(buildconfig),
groupId: calcGroupId(buildconfig),
]
}