all
Adds a dependency substitution rule that is triggered for every dependency (including transitive) when the configuration is being resolved. The action receives an instance of DependencySubstitution that can be used to find out what dependency is being resolved and to influence the resolution process.
Example:
configurations { main }
// add dependency substitution rules
configurations.main.resolutionStrategy.dependencySubstitution {
// Use a rule to change the dependency module while leaving group + version intact
all { DependencySubstitution dependency ->
if (dependency.requested instanceof ModuleComponentSelector && dependency.requested.module == 'groovy-all') {
dependency.useTarget dependency.requested.group + ':groovy:' + dependency.requested.version
}
}
// Use a rule to replace all missing projects with module dependencies
all { DependencySubstitution dependency ->
if (dependency.requested instanceof ProjectComponentSelector) {
def targetProject = findProject(":${dependency.requested.path}")
if (targetProject == null) {
dependency.useTarget "org.myorg:" + dependency.requested.path + ":+"
}
}
}
}
Content copied to clipboard
Return
this