在 Gradle 中排除传递依赖

m_Z*_*m_Z 3 gradle transitive-dependency build.gradle

在通过 Gradle 构建期间,我得到了这个

POM relocation to an other version number is not fully supported in Gradle : xml-apis:xml-apis:2.0.2 relocated to xml-apis:x
ml-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.
Run Code Online (Sandbox Code Playgroud)

项目中使用了蜡染 1.7。此版本的 Batik 使用 Xalan 2.6.0,它依赖于已重新定位的 xml-apis 2.0.2。

如何解决这种传递依赖?

lan*_*ava 8

选项1:

configurations.all {
    resolutionStrategy {
        force 'xml-apis:xml-apis:1.0.b2'
    }
}
Run Code Online (Sandbox Code Playgroud)

参见ResolutionStrategy.force(...)

选项 2:

dependencies {
    compile "batik:batik:$batikVersion", {
       exclude group: "xml-apis", module: "xml-apis"
    }
    compile "xml-apis:xml-apis:1.0.b2"
}
Run Code Online (Sandbox Code Playgroud)

ModuleDependency.exclude(Map)