Package org.gradle.api.artifacts
Interface ComponentSelectionRules
-
public interface ComponentSelectionRulesRepresents a container for component selection rules. Rules can be applied as part of the resolutionStrategy of a configuration and individual components can be explicitly accepted or rejected by rule. Components that are neither accepted or rejected will be subject to the default version matching strategies.configurations { conf { resolutionStrategy { componentSelection { all { ComponentSelection selection -> if (selection.candidate.module == 'someModule' && selection.candidate.version == '1.1') { selection.reject("bad version '1.1' for 'someModule'") } } all { ComponentSelection selection -> if (selection.candidate.module == 'someModule' && selection.getDescriptor(IvyModuleDescriptor)?.branch == 'testing') { if (selection.metadata == null || selection.metadata.status != 'milestone') { selection.reject("only use milestones for someModule:testing") } } } withModule("org.sample:api") { ComponentSelection selection -> if (selection.candidate.version == "1.1") { selection.reject("known bad version") } } } } } }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ComponentSelectionRulesall(Closure<?> closure)Adds a component selection rule that will apply to all resolved components.ComponentSelectionRulesall(Object ruleSource)Adds a rule-source backed component selection rule that will apply to all resolved components.ComponentSelectionRulesall(Action<? super ComponentSelection> selectionAction)Adds a simple component selection rule that will apply to all resolved components.ComponentSelectionRuleswithModule(Object id, Closure<?> closure)Adds a component selection rule that will apply to the specified module.ComponentSelectionRuleswithModule(Object id, Object ruleSource)Adds a rule-source backed component selection rule that will apply to the specified module.ComponentSelectionRuleswithModule(Object id, Action<? super ComponentSelection> selectionAction)Adds a component selection rule that will apply to the specified module.
-
-
-
Method Detail
-
all
ComponentSelectionRules all(Action<? super ComponentSelection> selectionAction)
Adds a simple component selection rule that will apply to all resolved components. Each rule will receive aComponentSelectionobject as an argument.- Parameters:
selectionAction- the Action that implements a rule to be applied- Returns:
- this
-
all
ComponentSelectionRules all(Closure<?> closure)
Adds a component selection rule that will apply to all resolved components. Each rule will receive aComponentSelectionobject as an argument. Injection of other arguments has been deprecated in favor of the added methods onComponentSelection, namelyComponentSelection.getMetadata()andComponentSelection.getDescriptor(Class).- Parameters:
closure- the Closure that implements a rule to be applied- Returns:
- this
-
all
ComponentSelectionRules all(Object ruleSource)
Adds a rule-source backed component selection rule that will apply to all resolved components. The ruleSource provides the rule as exactly one rule method annotated withMutate. This rule method:- must return void.
- must have
ComponentSelectionas its parameter.
ComponentSelection, namelyComponentSelection.getMetadata()andComponentSelection.getDescriptor(Class).- Parameters:
ruleSource- an instance providing a rule implementation- Returns:
- this
-
withModule
ComponentSelectionRules withModule(Object id, Action<? super ComponentSelection> selectionAction)
Adds a component selection rule that will apply to the specified module. Each rule will receive aComponentSelectionobject as an argument.- Parameters:
id- the module to apply this rule to in "group:module" format or as aModuleIdentifierselectionAction- the Action that implements a rule to be applied- Returns:
- this
-
withModule
ComponentSelectionRules withModule(Object id, Closure<?> closure)
Adds a component selection rule that will apply to the specified module. Each rule will receive aComponentSelectionobject as an argument. Injection of other arguments has been deprecated in favor of the added methods onComponentSelection, namelyComponentSelection.getMetadata()andComponentSelection.getDescriptor(Class).- Parameters:
id- the module to apply this rule to in "group:module" format or as aModuleIdentifierclosure- the Closure that implements a rule to be applied- Returns:
- this
-
withModule
ComponentSelectionRules withModule(Object id, Object ruleSource)
Adds a rule-source backed component selection rule that will apply to the specified module. The ruleSource provides the rule as exactly one rule method annotated withMutate. This rule method:- must return void.
- must have
ComponentSelectionas its parameter.
ComponentSelection, namelyComponentSelection.getMetadata()andComponentSelection.getDescriptor(Class).- Parameters:
id- the module to apply this rule to in "group:module" format or as aModuleIdentifierruleSource- an instance providing a rule implementation- Returns:
- this
-
-