| API文档: | ComponentSelectionRules |
|---|
表示组件选择规则的容器。规则可以作为配置的解决策略的一部分应用,并且规则可以明确地接受或拒绝各个组件。既不接受也不拒绝的组件将遵循默认的版本匹配策略。
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")
}
}
}
}
}
}
| 方法 | 描述 |
all(closure) | 添加将应用于所有已解析组件的组件选择规则。每个规则都会接收一个 |
all(ruleSource) | 添加规则源支持的组件选择规则,该规则将应用于所有解析的组件。 RuleSource 将规则提供为一种用 注释的规则方法 |
all(selectionAction) | 添加一个简单的组件选择规则,该规则将应用于所有已解析的组件。每个规则都会接收一个 |
withModule(id, closure) | 添加将应用于指定模块的组件选择规则。每个规则都会接收一个 |
withModule(id, ruleSource) | 添加将应用于指定模块的规则源支持的组件选择规则。 RuleSource 将规则提供为一种用 注释的规则方法 |
withModule(id, selectionAction) | 添加将应用于指定模块的组件选择规则。每个规则都会接收一个 |
ComponentSelectionRules all(Closure<?>关闭)
Closure<?>添加将应用于所有已解析组件的组件选择规则。每个规则都会接收一个ComponentSelection对象作为参数。
ComponentSelectionRules all(Object规则来源)
添加规则源支持的组件选择规则,该规则将应用于所有解析的组件。 RuleSource 将规则提供为一种用 注释的规则方法Mutate。本规则方法:
- 必须返回 void。
- 必须有
ComponentSelection作为其参数。
ComponentSelectionRules all(选择动作)Action<? super ComponentSelection>
Action<? super ComponentSelection>添加一个简单的组件选择规则,该规则将应用于所有已解析的组件。每个规则都会接收一个ComponentSelection对象作为参数。
ComponentSelectionRules withModule(Objectid,Closure<?>闭包)
Closure<?>添加将应用于指定模块的组件选择规则。每个规则都会接收一个ComponentSelection对象作为参数。
ComponentSelectionRules withModule(Objectid,Object规则源)
添加将应用于指定模块的规则源支持的组件选择规则。 RuleSource 将规则提供为一种用 注释的规则方法Mutate。本规则方法:
- 必须返回 void。
- 必须有
ComponentSelection作为其参数。
ComponentSelectionRules withModule( Objectid,选择动作)Action<? super ComponentSelection>
Action<? super ComponentSelection>添加将应用于指定模块的组件选择规则。每个规则都会接收一个ComponentSelection对象作为参数。