我试图通过我的gradle脚本从工件中获取所有单个依赖项的版本。问题是gradle只获取最新版本的依赖项,这导致我的applcation.where的问题我能够做到在maven中也一样。为什么gradle没有获取该依赖项的所有版本。下面是示例
dependencies {
runtime "carediscovery.services:GenericServices:1.0@jar"
runtime "carediscovery.services:GenericServices:1.1@jar"
runtime "carediscovery.services:GenericServices:1.2@jar"
runtime "carediscovery.services:GenericServices:1.3@jar"
runtime "carediscovery.services:GenericServices:1.5@jar"
runtime "carediscovery.services:GenericServices:1.6@jar"
runtime "carediscovery.services:LoadPathways:1.0@jar"
runtime "carediscovery.services:LoadPathways:1.1@jar"
}
Gradle脚本仅为GenericServices提取1.6版本。
有人可以告诉我,无论如何都要从gradle中获取1.0 ... 1.6中的所有依赖项吗?
我尝试了以下代码,但这给了我错误,有人可以告诉我为什么它给了我这个
apply plugin: 'java'
repositories {
maven {
url "http://cm.t.thn.com:8/artifactory/services-release-local"
}
}
def deps = [GenericServices: (0..6), LoadPathways: (0..1)]
deps.each { dep, version ->
configurations.create("$dep$version")
dependencies.add("$dep$version", "carediscovery.services:$dep:1.$version@jar")
}
task copy(type: Copy) {
from(deps.collect { dep -> dep.value.collect { configurations."$dep.key$it" } }.flatten())
into 'services/carediscovery/services'
}
以下是错误结果
**C:\NEW_HG_WORKSPACE\APPLICATION-DATA>gradle clean build
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\NEW_HG_WORKSPACE\APPLICATION-DATA\build.gradle' line: 20
* What went wrong:
A problem occurred evaluating root project 'application-data'.
> Could not find property 'GenericServices0' on configuration container.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED**
我修复了上述问题,现在工作正常
apply plugin: 'java'
repositories {
maven {
url "http://c.t.t.com:8/artifactory/services-release-local"
}
}
def deps = [GenericServices: (0..6), LoadPathways: (0..1)]
deps.each { dep, versions ->
versions.each { version ->
configurations.create("$dep$version")
dependencies.add("$dep$version", "carediscovery.services:$dep:1.$version@jar")
}
}
task copy(type: Copy) {
from(deps.collect { dep -> dep.value.collect { configurations."$dep.key$it" } }.flatten())
into 'services/carediscovery/services'
}