【问题标题】:Exclude transitive dependency in Gradle [duplicate]在 Gradle 中排除传递依赖
【发布时间】:2017-06-15 07:59:03
【问题描述】:

在通过 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.

项目中使用了 Batik 1.7。 这个版本的 Batik 使用 Xalan 2.6.0,它依赖于 xml-apis 2.0.2,它被重新定位。

如何解决这种传递依赖?

【问题讨论】:

    标签: gradle build.gradle transitive-dependency


    【解决方案1】:

    选项 1:

    configurations.all {
        resolutionStrategy {
            force 'xml-apis:xml-apis:1.0.b2'
        }
    }
    

    ResolutionStrategy.force(...)

    选项 2:

    dependencies {
        compile "batik:batik:$batikVersion", {
           exclude group: "xml-apis", module: "xml-apis"
        }
        compile "xml-apis:xml-apis:1.0.b2"
    }
    

    ModuleDependency.exclude(Map)

    【讨论】:

    • 在您的选项 2 中,您排除了特定版本并包括所需的版本。我的疑问是,在这种情况下,'x' jar 使用'y' jar,因此排除并包含我们想要的版本。但是假设'x' jar 使用'y' jar 再次使用'z' jar,那么如果我想要特定版本的'z' jar 我该怎么办?
    • “在您的选项 2 中,您排除了特定版本”这是不正确的。我没有指定版本。所以它排除了所有版本(不管 x/y 或 x/y/z 场景)。所以我可以明确地选择我想要的版本,知道它不包含在 batik(或任何 batik 的传递依赖项)中
    猜你喜欢
    • 1970-01-01
    • 2015-05-15
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    • 2021-07-26
    • 2021-04-11
    • 2012-12-05
    • 1970-01-01
    相关资源
    最近更新 更多