Artifactory Gradle分辨率URL不正确且不一致

时间:2017-02-22 18:08:20

标签: maven gradle artifactory

我有一个Artifactory(版本4.15.0)实例,为Maven2存储库提供了几个工件。 Gradle(版本3.3)可以很好地解析和下载大多数依赖项。但是,有些人无法解决Gradle Artifactory插件解析器查找错误URL的奇怪错误。有趣的是,正确的URL用于定位POM,然后当它尝试下载JAR时,使用了错误的URL。

POM网址

[DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request HEAD http://artifactoryLocation:8081/artifactory/libs-release/org/swinglabs/swingx/swingx-all/1.6.5-1/swingx-all-1.6.5-1.pom HTTP/1.1

JAR网址

[DEBUG] [org.gradle.internal.resource.transport.http.HttpClientHelper] Performing HTTP HEAD: http://artifactoryLocation:8081/artifactory/libs-release/org.swinglabs.swingx/swingx-all/1.6.5-1/swingx-all-1.6.5-1.jar

正如您所看到的,使用的JAR网址包含.而非/。我不确定为什么会这样。正确下载POM,而JAR依赖项无法解析和下载。有任何修复建议吗?

另一个有趣的发现是使用了artifactory-ivy-resolver而不是artifactory-maven-resolver。如上所述,存储库是Artifactory中的Maven2存储库,并在Gradle build.gradle文件中说明 - 没有提及常春藤,但正在使用常春藤解析器。我不确定这是否是问题的一部分。

的build.gradle

apply plugin: 'java'
apply plugin: 'com.jfrog.artifactory'

repositories {

}

buildscript {
  repositories {
    maven {
        url 'http://artifactoryLocation:8081/artifactory/libs-release'
        credentials {
            username = "${artifactory_user}"
            password = "${artifactory_password}"
        }
    }

    jcenter()
  }
  dependencies {
    //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
  }
}

dependencies {
  compile 'javax.media:jmf:2.1.1e'
  compile 'com.bbn.openmap:openmap:5.0'
  compile 'org.igniterealtime.smack:smack:3.2.2'
  compile 'org.igniterealtime.smack:smackx:3.2.2'
  compile 'org.swinglabs.swingx:swingx-all:1.6.5-1'
  compile 'gov.nasa.worldwind:worldwind:2.1.0'
}

artifactory {
  contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
  publish {
    repository {
        repoKey = 'libs-release-local'
        username = "${artifactory_user}"
        password = "${artifactory_password}"
        maven = true
    }
  }
  resolve {
    repository {
        repoKey = 'libs-release'
        username = "${artifactory_user}"
        password = "${artifactory_password}"
        maven = true
    }
  }
}

1 个答案:

答案 0 :(得分:0)

在我也使用Artifactory的项目中,我使用Artifactory Gradle插件进行发布。作为源回购定义,我使用类似的东西:

repositories {
    maven {
        url 'http://artifactoryLocation:8081/artifactory/libs-release'
        credentials {
            username = "${artifactory_user}"
            password = "${artifactory_password}"
        }
    }
}

请尝试将它放到build.gradle中。