【问题标题】:Is there a maven plugin that will verify conflicting versions of transitive dependencies?是否有一个 Maven 插件可以验证传递依赖项的冲突版本?
【发布时间】:2014-09-30 15:43:45
【问题描述】:
是否有一个 Maven 插件可以验证传递依赖项的冲突版本,确保我不依赖于同一工件的不同版本?
理想情况下,我会挂接到 compile 生命周期,如果我同时导入依赖项 A 的版本 X 和 Y,它会导致构建失败。
【问题讨论】:
标签:
maven
transitive-dependency
【解决方案1】:
您可以使用 maven-enforcer-plugin 来完成。如果版本冲突,以下配置将导致构建失败:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce</id>
<configuration>
<rules>
<DependencyConvergence/>
</rules>
</configuration>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
这里有更多细节:
http://maven.apache.org/enforcer/enforcer-rules/dependencyConvergence.html