对于我的构建,我需要根据一些条件逻辑有条件地解析一个jar。我需要jar文件的位置,而不是将其放入特定构建或运行时配置的类路径中。
if (platform == "jdk8alpn") {
// Add alpn-boot on Java 8 so we can use HTTP/2 without a stable API.
def alpnBootVersion = alpnBootVersion()
if (alpnBootVersion != null) {
dependencies {
testCompile "org.mortbay.jetty.alpn:alpn-boot:$alpnBootVersion"
}
def alpnBootJar = configurations.testCompile.find { it.name.startsWith("alpn-boot-") } <-- fails here
test {
jvmArgs += "-Xbootclasspath/p:${alpnBootJar}"
}
}
}
现在失败了
如何将jar解析为本地路径?
仅为该工件创建配置
def jarPath = configurations.detachedConfiguration(
dependencies.create("org.mortbay.jetty.alpn:alpn-boot:$alpnBootVersion")
).singleFile