52 строки
2.5 KiB
Groovy
52 строки
2.5 KiB
Groovy
// This script is designed to be used by consuming apps that want to support locally-published
|
|
// development versions of application-services components. A build that `apply from`'s this script
|
|
// will be configured to look for development versions published to the local maven repository.
|
|
//
|
|
// There is a companion gradle command `autoPublishForLocalDevelopment` that can be used to publish
|
|
// the local development versions that are targetted by this script.
|
|
|
|
def version = null
|
|
if (gradle.hasProperty("localProperties.autoPublish.application-services.dir")) {
|
|
// We're doing local development using the autoPublish system. This automatically rebuilds and
|
|
// publishes application-services packages whenever the source changes.
|
|
// This version string will selected the latest build package
|
|
version = '0.0.1-SNAPSHOT-+'
|
|
|
|
} else if (gradle.hasProperty("localProperties.branchBuild.application-services.version")) {
|
|
// We're running a branch build. Here the version is set to the git commit id in
|
|
// local.properties
|
|
version = gradle.getProperty("localProperties.branchBuild.application-services.version")
|
|
} else {
|
|
throw new Exception("substitute-local-appservices.gradle called from unexpected context")
|
|
}
|
|
logger.lifecycle("[local-appservices] adjusting ${project} to use locally published application-services modules (${version})")
|
|
|
|
// Inject mavenLocal repository. This is where we're expected to publish modules.
|
|
repositories {
|
|
mavenLocal()
|
|
}
|
|
|
|
configurations.all { config ->
|
|
if (config.isCanBeResolved()) {
|
|
config.resolutionStrategy { strategy ->
|
|
dependencySubstitution {
|
|
all { dependency ->
|
|
// We only care about substituting for a module, not a project.
|
|
if (!(dependency.requested instanceof ModuleComponentSelector)) {
|
|
return
|
|
}
|
|
|
|
def group = dependency.requested.group
|
|
if (group == 'org.mozilla.appservices' || group == 'org.mozilla.appservices.nightly') {
|
|
def name = dependency.requested.module
|
|
// Although there are a number of app-services group names which might be configured,
|
|
// our local publish flow always uses exactly `org.mozilla.appservices`
|
|
dependency.useTarget([group: 'org.mozilla.appservices', name: name, version: version])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|