Table of Contents
API Documentation: | ComponentMetadataHandler |
---|
Allows the build to provide rules that modify the metadata of depended-on software components.
Possible uses of component metadata rules are:
- Setting the status and status scheme of a component, overriding the value specified in the component descriptor.
- Declaring whether or not a component is 'changing', thus impacting the cache behaviour of the component.
Example:
dependencies { components { // Set the status and status scheme for every component belonging to a module in the group "org.foo" all { 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"] } } // Treat all components in the module "org.foo:bar" as changing withModule("org.foo:bar") { ComponentMetadataDetails details -> details.changing = true } } }
Method | Description |
all(rule) | Adds a rule closure that may modify the metadata of any resolved software component. |
all(rule) | Incubating Adds a class based rule that may modify the metadata of any resolved software component. |
all(rule, configureAction) | Incubating Adds a class based rule that may modify the metadata of any resolved software component. The rule itself is configured by the provided configure action. |
all(ruleSource) | Adds a rule that may modify the metadata of any resolved software component. |
all(rule) | Adds a rule action that may modify the metadata of any resolved software component. |
withModule(id, rule) | Adds a rule that may modify the metadata of any resolved software component belonging to the specified module. |
withModule(id, rule) | Incubating Adds a class based rule that may modify the metadata of any resolved software component belonging to the specified module. |
withModule(id, rule, configureAction) | Incubating Adds a class based rule that may modify the metadata of any resolved software component belonging to the specified module. |
withModule(id, ruleSource) | Adds a rule that may modify the metadata of any resolved software component belonging to the specified module. |
withModule(id, rule) | Adds a rule that may modify the metadata of any resolved software component belonging to the specified module. |
Adds a rule closure that may modify the metadata of any resolved software component.
The supplied rule closure 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 not significant.
The following additional parameter types are supported:
IvyModuleDescriptor
- additional Ivy-specific metadata. Rules declaring this parameter will only be invoked for components packaged as an Ivy module.
ComponentMetadataHandler
all
(Class
<? extends ComponentMetadataRule
>
rule)
Class
<? extends ComponentMetadataRule
>Note: This method is incubating and may change in a future version of Gradle.
Adds a class based rule that may modify the metadata of any resolved software component.
ComponentMetadataHandler
all
(Class
<? extends ComponentMetadataRule
>
rule, Action
<? super ActionConfiguration
>
configureAction)
Class
<? extends ComponentMetadataRule
>Action
<? super ActionConfiguration
>Note: This method is incubating and may change in a future version of Gradle.
Adds a class based rule that may modify the metadata of any resolved software component. The rule itself is configured by the provided configure action.
ComponentMetadataHandler
all
(Object
ruleSource)
Adds a rule that may modify the metadata of any resolved software component.
The ruleSource is an Object that has a single rule method annotated with Mutate
.
This rule method:
- must return void.
- must have
ComponentMetadataDetails
as the first parameter. - may have an additional parameter of type
IvyModuleDescriptor
.
ComponentMetadataHandler
all
(Action
<? super ComponentMetadataDetails
>
rule)
Action
<? super ComponentMetadataDetails
>Adds a rule action that may modify the metadata of any resolved software component.
Adds a rule that may modify the metadata of any resolved software component belonging to the specified module.
The rule closure parameter is subject to the same requirements as ComponentMetadataHandler.all(groovy.lang.Closure)
.
ComponentMetadataHandler
withModule
(Object
id, Class
<? extends ComponentMetadataRule
>
rule)
Class
<? extends ComponentMetadataRule
>Note: This method is incubating and may change in a future version of Gradle.
Adds a class based rule that may modify the metadata of any resolved software component belonging to the specified module.
ComponentMetadataHandler
withModule
(Object
id, Class
<? extends ComponentMetadataRule
>
rule, Action
<? super ActionConfiguration
>
configureAction)
Class
<? extends ComponentMetadataRule
>Action
<? super ActionConfiguration
>Note: This method is incubating and may change in a future version of Gradle.
Adds a class based rule that may modify the metadata of any resolved software component belonging to the specified module.
ComponentMetadataHandler
withModule
(Object
id, Object
ruleSource)
Adds a rule that may modify the metadata of any resolved software component belonging to the specified module.
The rule source parameter is subject to the same requirements as ComponentMetadataHandler.all(java.lang.Object)
.
ComponentMetadataHandler
withModule
(Object
id, Action
<? super ComponentMetadataDetails
>
rule)
Action
<? super ComponentMetadataDetails
>Adds a rule that may modify the metadata of any resolved software component belonging to the specified module.