Allows to modify the metadata of depended-on software components.
Example:
dependencies { components { //triggered during dependency resolution, for each component: eachComponent { ComponentMetadataDetails details -> if (details.id.group == "org.foo") { def version = details.id.version // assuming status is last part of version string details.status = version.substring(version.lastIndexOf("-") + 1) details.statusScheme = ["bronze", "silver", "gold", "platinum"] } } //Configuring component module metadata for the entire "google-collections" module, // declaring that legacy library was replaced with "guava". //This way, Gradle's conflict resolution can use this information and use "guava" // in case both libraries appear in the same dependency tree. module("com.google.collections:google-collections").replacedBy("com.google.guava:guava") } }
Type | Name and description |
---|---|
void |
eachComponent(Action<? super ComponentMetadataDetails> rule) Adds a rule to modify the metadata of depended-on software components. |
void |
eachComponent(Closure<?> rule) Adds a rule to modify the metadata of depended-on software components. |
ComponentModuleMetadataDetails |
module(Object moduleNotation) Enables configuring component module metadata. |
Adds a rule to modify the metadata of depended-on software components. For example, this allows to set a component's status and status scheme from within the build script, overriding any value specified in the component descriptor.
rule
- the rule to be addedAdds a rule to modify the metadata of depended-on software components. For example, this allows to set a component's status and status scheme from within the build script, overriding any value specified in the component descriptor.
The rule must declare a ComponentMetadataDetails as it's first parameter, allowing the component metadata to be modified.
In addition, the rule can declare additional (read-only) parameters, which may provide extra details about the component. The order of these additional parameters is irrelevant.
Presently, the following additional parameter types are supported:
rule
- the rule to be addedEnables configuring component module metadata. This metadata applies to the entire component module (e.g. "group:name", like "org.gradle:gradle-core") regardless of the component version.
//declaring that google collections are replaced by guava //so that conflict resolution can take advantage of this information: dependencies.components.module('com.google.collections:google-collections').replacedBy('com.google.guava:guava')
moduleNotation
- an identifier of the module. String "group:name", e.g. 'org.gradle:gradle-core'
or an instance of ModuleIdentifier