Gradle下载依赖项错误

16

我正在尝试添加以下依赖项:

compile group: 'com.cedarsoft.commons', name:'test-utils', version:'5.0.9'

Gradle下载了几个JAR文件,然后我遇到了以下错误:

POM relocation to an other version number is not fully supported in Gradle : xml-apis#xml-apis;2.0.2   relocated to xml-apis#xml-apis;1.0.b2.
Please update your dependency to directly use the correct version 'xml-apis#xml-apis;1.0.b2'.
Resolution will only pick dependencies of the relocated element.  Artifacts and other metadata will    be ignored.

有什么想法为什么会出现这个问题以及如何解决?

2个回答

21
configurations.all {
    resolutionStrategy {
        force 'xml-apis:xml-apis:1.4.01'
    }
}

或者使用1.0.b2版本。问题在于xml-apis的POM会将2.0.2重定向到相同的组和构件,只有版本是1.0.b2,这会以某种方式欺骗Gradle(或基础Ivy)的解析机制。

功劳归于Mark Petrovic Gradle论坛


Gradle论坛链接目前已经失效 :( - Deep Singh Baweja

8
如果你查看Maven Central中的构件并下载pom文件,你会得到以下内容:
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>xml-apis</groupId>
  <artifactId>xml-apis</artifactId>
  <version>2.0.2</version>
  <distributionManagement>
  <relocation>
    <groupId>xml-apis</groupId>
    <artifactId>xml-apis</artifactId>
    <version>1.0.b2</version>
  </relocation>
  </distributionManagement>
</project>

这意味着该工件可以在新坐标下找到,这意味着您需要使用新坐标来使用该工件。我假设您没有直接使用该工件,而是通过传递依赖关系使用的。这意味着您需要使用新工件坐标覆盖传递依赖关系。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接