Maven enforcer插件正在识别我正在使用的第三方库的代码收敛问题。我如何在项目的其余部分运行enforcer插件的同时忽略这个问题,或者我应该如何在不改变库版本的情况下解决这个问题?
我的项目使用的是camel-cxf 2.13.2,它依赖于jaxb-impl的两个独立的过渡版本: 2.1.13和2.2.6。enforcer插件会识别出这一点,并导致构建失败。
下面是我如何配置插件的:
<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发布于 2019-01-11 00:31:27
最后,我将排除项添加到特定子依赖项中,这些子依赖项引入了较旧的、冲突的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>这样,我仍然可以在项目的其余部分运行enforcer插件,并且如果发现新的收敛问题,构建将失败。
发布于 2019-01-10 01:41:51
我认为当存在收敛错误时,您不希望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.x.x。
https://stackoverflow.com/questions/54115522
复制相似问题