gradle
8.4

# withModule

abstract fun withModule(id: Any, selectionAction: Action<out Any>): ComponentSelectionRules(source)

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

#### Return

this

#### 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

abstract fun withModule(id: Any, @DelegatesTo(value = ComponentSelection::class) closure: Closure<out Any>): ComponentSelectionRules(source)

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

#### Return

this

#### 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

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

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:

- must return void.
- must have org.gradle.api.artifacts.ComponentSelection as its parameter.

#### Return

this

#### 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