101 lines
3.9 KiB
Groovy
101 lines
3.9 KiB
Groovy
/* 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
|
|
|
|
buildscript {
|
|
if (!gradle.root.hasProperty("mozconfig")){
|
|
apply from: file('./gradle/mozconfig.gradle')
|
|
} else {
|
|
gradle.ext.mozconfig = gradle.root.mozconfig
|
|
gradle.ext.configureMavenRepositories = gradle.root.ext.configureMavenRepositories
|
|
}
|
|
|
|
repositories {
|
|
gradle.configureMavenRepositories(delegate)
|
|
}
|
|
|
|
dependencies {
|
|
classpath 'org.yaml:snakeyaml:2.2'
|
|
}
|
|
}
|
|
|
|
if (!gradle.root.hasProperty("mozconfig")){
|
|
apply from: file('./gradle/mozconfig.gradle')
|
|
} else {
|
|
gradle.ext.mozconfig = gradle.root.mozconfig
|
|
gradle.ext.configureMavenRepositories = gradle.root.ext.configureMavenRepositories
|
|
}
|
|
|
|
// 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 jvmTargetCompatibility
|
|
public final Integer compileSdkMajorVersion
|
|
public final Integer compileSdkMinorVersion
|
|
public final Integer minSdkVersion
|
|
public final Integer targetSdkVersion
|
|
public final String ndkVersion
|
|
|
|
|
|
Config(
|
|
String componentsVersion,
|
|
String componentsGroupId,
|
|
Integer jvmTargetCompatibility,
|
|
Integer compileSdkMajorVersion,
|
|
Integer compileSdkMinorVersion,
|
|
Integer minSdkVersion,
|
|
Integer targetSdkVersion,
|
|
String ndkVersion
|
|
) {
|
|
this.componentsVersion = componentsVersion
|
|
this.componentsGroupId = componentsGroupId
|
|
this.jvmTargetCompatibility = jvmTargetCompatibility
|
|
this.compileSdkMajorVersion = compileSdkMajorVersion
|
|
this.compileSdkMinorVersion = compileSdkMinorVersion
|
|
this.minSdkVersion = minSdkVersion
|
|
this.targetSdkVersion = targetSdkVersion
|
|
this.ndkVersion = ndkVersion
|
|
}
|
|
}
|
|
|
|
gradle.projectsLoaded { ->
|
|
def versionFile = new File(gradle.mozconfig.topsrcdir, "mobile/android/version.txt")
|
|
String version = versionFile.text.stripTrailing()
|
|
|
|
def yaml = new Yaml()
|
|
def configDataFile = new File(gradle.mozconfig.topsrcdir, "mobile/android/android-components/.config.yml")
|
|
def configData = yaml.load(configDataFile.newInputStream())
|
|
|
|
if (gradle.rootProject.hasProperty("nightlyVersion")) {
|
|
version = gradle.rootProject.nightlyVersion
|
|
} else if (gradle.rootProject.hasProperty("local")) {
|
|
// To support local auto-publication workflow, we use a version prefix we wouldn't normally encounter.
|
|
version = "0.0.1"
|
|
} else if (gradle.hasProperty("localProperties.branchBuild.android-components.version")) {
|
|
version = gradle.getProperty("localProperties.branchBuild.android-components.version")
|
|
}
|
|
// get the ndk version from the external build environment.
|
|
def ndkVersion = "${gradle.mozconfig.substs.ANDROID_NDK_MAJOR_VERSION}.${gradle.mozconfig.substs.ANDROID_NDK_MINOR_VERSION}"
|
|
|
|
// 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(
|
|
version,
|
|
configData.componentsGroupId,
|
|
configData.jvmTargetCompatibility,
|
|
configData.compileSdkMajorVersion,
|
|
configData.compileSdkMinorVersion,
|
|
configData.minSdkVersion,
|
|
configData.targetSdkVersion,
|
|
ndkVersion
|
|
)
|
|
}
|