with Dependencies
Execute the given action before the configuration first participates in dependency resolution. Actions will be executed in the order provided. A configuration will participate in dependency resolution when:
- The Configuration itself is resolved
- The Configuration is published to a repository
- The Configuration is consumed as a variant by another project
- Another Configuration that extends this one is resolved, published, or consumed
In general, this method should be avoided in favor of other lazy APIs. However, in some cases where lazy APIs are not yet available, this method can be used to perform actions before the configuration is used.
Despite the method's name, callbacks registered on this method should not add dependencies to the configuration or mutate the dependencies already present on the configuration. Instead, use the Provider-accepting methods on DependencySet and DependencyConstraintSet.
Consider the following example that lazily adds a dependency to a configuration:
configurations { conf }
configurations['conf'].dependencies.addLater(provider {
project.dependencies.create("com:example:1.0")
})
configurations { conf }
dependencies {
conf("com:example")
constraints {
conf("com:example") {
version {
prefer("2.0")
}
}
}
}
- Adding excludes: This method may be used to lazily add excludes to a Configuration. Adding excludes to declared dependencies should be handled with component metadata rules
- Mutating configuration hierarchy: Mutating a configuration's hierarchy (extendsFrom) after declaration is highly discouraged. However, doing so is possible with this method.
Since
4.4
Return
this
Parameters
a dependency action to execute before the configuration is used.