2

Maven 执行器插件正在识别我正在使用的第 3 方库的代码融合问题。如何在项目的其余部分仍然运行强制执行器插件的同时忽略这一点,或者我应该如何在不更改库版本的情况下解决问题?

我的项目camel-cxf使用 2.13.2 ,结果证明它依赖于两个单独的传递版本jaxb-impl;2.1.13 和 2.2.6。执行器插件识别出这一点并导致构建失败。

这是我配置插件的方式:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.3.1</version>
        <configuration>
            <rules>
                <DependencyConvergence/>
            </rules>
        </configuration>
    </plugin>

当我跑步时,mvn enforcer:enforce我得到

Rule 0: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for com.sun.xml.bind:jaxb-impl:2.2.6 paths to dependency are:
+-com.myModule:module:18.0.0-SNAPSHOT
  +-org.apache.camel:camel-cxf:2.13.2
    +-org.apache.camel:camel-core:2.13.2
      +-com.sun.xml.bind:jaxb-impl:2.2.6
and
+-com.myModule:module:18.0.0-SNAPSHOT
  +-org.apache.camel:camel-cxf:2.13.2
    +-org.apache.cxf:cxf-rt-bindings-soap:2.7.11
      +-org.apache.cxf:cxf-rt-databinding-jaxb:2.7.11
        +-com.sun.xml.bind:jaxb-impl:2.1.13
and
+-com.myModule:module:18.0.0-SNAPSHOT
  +-org.apache.cxf:cxf-rt-management:2.7.11
    +-org.apache.cxf:cxf-rt-core:2.7.11
      +-com.sun.xml.bind:jaxb-impl:2.1.13
4

2 回答 2

2

最后,我向特定的子依赖项添加了排除项,这些子依赖项引入了旧的、冲突的 jaxb-impl 版本。

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-core</artifactId>
    <version>${cxf.version}</version>
    <exclusions>
        <exclusion>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
        </exclusion>
    </exclusions>
    <scope>${framework.scope}</scope>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-databinding-jaxb</artifactId>
    <version>${cxf.version}</version>
    <exclusions>
        <exclusion>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
        </exclusion>
    </exclusions>
</dependency>

这样我仍然可以在项目的其余部分上运行强制插件,如果发现新的收敛问题,则构建失败。

于 2019-01-10T16:31:27.317 回答
1

我认为您不希望 Maven 在出现收敛错误时使构建阶段失败。在这种情况下,您需要在配置中设置 fail = false 标志,以便它只会注销收敛错误并继续下一阶段。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>3.0.0-M1</version>
  <executions>
    <execution>
      <id>dependency-convergence</id>
      <phase>install</phase>
      <goals>
        <goal>enforce</goal>
      </goals>
      <configuration>
        <rules>
          <DependencyConvergence />
        </rules>
        <fail>false</fail>
      </configuration>
    </execution>
    <executions>
      <plugin>

注意:maven-enforcer-plugin 版本 1.3.1 非常旧。考虑将其升级到最新的 3.xx

于 2019-01-09T17:41:50.613 回答