简体   繁体   English

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

[英]How can Maven Shade Plugin relocate multiple versions of a transitive dependency?

I have two dependencies, artifact-a and artifact-b . 我有两个依赖项, 工件-a工件-b Each depends on a different version of artifact-c . 每个依赖于工件-c的不同版本。 How can I shade artifacts to use these different dependencies? 如何遮挡工件以使用这些不同的依赖关系? (Or else to have artifact-a use a shaded dependency and artifact-b use the normal one. (或者让伪像-a使用阴影依赖项, 伪像-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>

This can probably done by creating new Maven modules whose only purpose is to shade artifact-a and its dependencies (respectively artifact-b ). 这可能可以通过创建新的Maven模块来完成,该模块的唯一目的是遮盖工件-a及其依赖项(分别是工件-b )。 Then, the main module would depend on these two new modules. 然后,主模块将依赖于这两个新模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM