application-services/build-scripts/substitute-local-appservice...

39 строки
1.7 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.
logger.lifecycle("[local-appservices] adjusting ${project} to use locally published application-services modules")
// 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
}
// For every org.mozilla.appservices.* module, substitute its version for one
// formatted like `0.0.1-SNAPSHOT-*`. This syntax will pick the latest such version
// published locally by the `autoPublishForLocalDevelopment` command.
def group = dependency.requested.group
if (group == 'org.mozilla.appservices') {
def name = dependency.requested.module
dependency.useTarget([group: group, name: name, version: '0.0.1-SNAPSHOT-+'])
}
}
}
}
}
}