Maven Shade插件如何重定位传递依赖的多个版本?

时间:2017-01-08 13:09:35

标签: java maven dependency-management maven-shade-plugin build-dependencies

我有两个依赖项, artifact-a artifact-b 。每个都取决于 artifact-c 的不同版本。如何遮蔽工件以使用这些不同的依赖项? (或者让 artifact-a 使用阴影依赖项, artifact-b 使用正常依赖项。

        <dependency>
            <groupId>group-a</groupId>
            <artifactId>artifact-a</artifactId>
            <version>2.1.0</version>
<!-- artifact-a uses version 3 of artifact-c.
How do I relocate version 3 without conflicting with version 4?
                <groupId>group-c</groupId>
                <artifactId>artifact-c</artifactId>
                <version>3.0.0</version>
-->
      </dependency>
        <dependency>
            <groupId>group-b</groupId>
            <artifactId>artifact-b</artifactId>
            <version>1.5.0</version>
<!-- artifact-b uses version 4 of artifact-c. 
How do I relocate version 4 without conflicting with version 3?
                <groupId>group-c</groupId>
                <artifactId>artifact-c</artifactId>
                <version>4.0.0</version>
-->
      </dependency>

1 个答案:

答案 0 :(得分:0)

这可以通过创建新的Maven模块来完成,该模块的唯一目的是遮蔽 artifact-a 及其依赖项(分别为 artifact-b )。然后,主模块将依赖于这两个新模块。