Gradle 如何解决基于坐标字符串的梯度依赖关系

Gradle 如何解决基于坐标字符串的梯度依赖关系,gradle,Gradle,对于我的构建,我需要根据一些条件逻辑有条件地解析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 !=

对于我的构建,我需要根据一些条件逻辑有条件地解析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}"
      }
    }
  }
if(平台==“jdk8alpn”){
//在Java8上添加alpn引导,这样我们就可以在没有稳定API的情况下使用HTTP/2。
def alpnBootVersion=alpnBootVersion()
if(alpnBootVersion!=null){
依赖关系{
testCompile“org.mortbay.jetty.alpn:alpn引导:$alpnBootVersion”
}

def alpnBootJar=configurations.testCompile.find{it.name.startsWith(“alpn boot-”)}为该工件创建一个配置

def jarPath = configurations.detachedConfiguration(
  dependencies.create("org.mortbay.jetty.alpn:alpn-boot:$alpnBootVersion")
).singleFile