在下面的示例中,我具有3个依赖项,它们具有相同的组和相同的版本。我想将这三个依赖项分组在一行中。
compile group: 'org.apache.ws.commons.axiom', name: 'axiom-api', version: '1.2.7'
compile group: 'org.apache.ws.commons.axiom', name: 'axiom-dom', version: '1.2.7'
compile group: 'org.apache.ws.commons.axiom', name: 'axiom-impl', version: '1.2.7'
预期如下group("axiom-api", "axiom-dom", "axiom-impl", :under=>"org.apache.ws.commons.axiom", :version=>"1.2.7")
gradle
是否可能? 最佳答案
好吧,实际上总共有更多行,但是如果这个(相同的组,相同的版本和多个 Artifact )是重复的模式,则可能仍然很方便:
def groupDependencies ( group, names, version ) {
def deps = []
names.each { it ->
deps += [group: group, name: it, version: version]
}
return deps
}
dependencies {
compile(groupDependencies('org.apache.ws.commons.axiom', ['axiom-api', 'axiom-dom', 'axiom-impl'], '1.2.7'))
}