api / org.gradle.api.artifacts / ComponentSelectionRules / withModule

withModule

abstract fun withModule(id: Any, selectionAction: Action<in ComponentSelection>): ComponentSelectionRules

Adds a component selection rule that will apply to the specified module. Each rule will receive a ComponentSelection object as an argument.

Parameters

id - the module to apply this rule to in "group:module" format or as a org.gradle.api.artifacts.ModuleIdentifier

selectionAction - the Action that implements a rule to be applied

Return
this

abstract fun withModule(id: Any, closure: Closure<*>): ComponentSelectionRules

Adds a component selection rule that will apply to the specified module. Each rule will receive a ComponentSelection object as an argument as well as any other arguments specified for the closure. Allowable closure arguments are ComponentSelection (required), org.gradle.api.artifacts.ComponentMetadata and/or org.gradle.api.artifacts.ivy.IvyModuleDescriptor.

Parameters

id - the module to apply this rule to in "group:module" format or as a org.gradle.api.artifacts.ModuleIdentifier

closure - the Closure that implements a rule to be applied

Return
this

abstract fun withModule(id: Any, ruleSource: Any): ComponentSelectionRules

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 with org.gradle.model.Mutate. This rule method:

Parameters

id - the module to apply this rule to in "group:module" format or as a org.gradle.api.artifacts.ModuleIdentifier

ruleSource - an instance providing a rule implementation

Return
this