排除Gradle中的传递依赖项

排除Gradle中的传递依赖项,gradle,build.gradle,transitive-dependency,Gradle,Build.gradle,Transitive Dependency,在通过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

在通过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.
项目采用蜡染1.7。 这个版本的Batik使用Xalan 2.6.0,它依赖于xml API 2.0.2,而xml API 2.0.2被重新定位


如何解决此可传递依赖关系?

选项1:

configurations.all {
    resolutionStrategy {
        force 'xml-apis:xml-apis:1.0.b2'
    }
}
dependencies {
    compile "batik:batik:$batikVersion", {
       exclude group: "xml-apis", module: "xml-apis"
    }
    compile "xml-apis:xml-apis:1.0.b2"
}

选项2:

configurations.all {
    resolutionStrategy {
        force 'xml-apis:xml-apis:1.0.b2'
    }
}
dependencies {
    compile "batik:batik:$batikVersion", {
       exclude group: "xml-apis", module: "xml-apis"
    }
    compile "xml-apis:xml-apis:1.0.b2"
}

请参见选项2中的

,您排除了特定版本,包括了所需的版本。我的疑问是,在这种情况下,“x”jar使用“y”jar,因此排除并包含我们想要的版本。但是假设'x'jar使用'y'jar,而'y'jar又使用了'z'jar,那么如果我想要'z'jar的特定版本,我该怎么办?“在您的选项2中,您排除了一个特定版本”,这是不正确的。我没有指定版本。因此它排除了所有版本(不管x/y或x/y/z场景)。因此,我可以明确选择我想要的版本,知道它不包括在batik中(或batik的任何可传递依赖项中)