1
我正在使用内部框架作为其依赖关系之一的大型多模块项目。框架版本在项目开始时设置在顶层pom中,并且必须保持不变。如果任何子模块使用不同的版本,我想构建失败。如何失败Maven构建依赖冲突
我用尽声明依赖作为一个单一的版本:
<dependency>
<groupId>framework_snt</groupId>
<artifactId>SFP</artifactId>
<version>[6.1]</version>
<type>pom</type>
</dependency>
使用实施者插件与禁止依赖
我用尽:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.6.0-21]</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[3.0.3]</version>
</requireMavenVersion>
<bannedDependencies>
<excludes>
<exclude>framework_snt:SFP</exclude>
</excludes>
<includes>
<include>framework_snt:SFP:6.1.2</include>
</includes>
</bannedDependencies>
</rules>
</configuration>
</execution>
</executions>
</plugin>
香港专业教育学院也尝试添加了<DependencyConvergence/>
标签提到here,但这些方法都不起作用。
所以给这个顶层POM片段:
<project>
<groupId>glb</groupId>
<artifactId>GLB</artifactId>
<packaging>pom</packaging>
<name>Global</name>
<version>1.0</version>
........
<dependencies>
<dependency>
<groupId>framework_snt</groupId>
<artifactId>SFP</artifactId>
<version>[6.1.2]</version>
<type>pom</type>
</dependency>
</dependencies>
.....
</project>
而这个(无效)submmodule:
<project>
<groupId>glb</groupId>
<artifactId>CORE</artifactId>
<packaging>jar</packaging>
<name>Core</name>
<version>1.0</version>
<parent>
<groupId>glb</groupId>
<artifactId>GLB</artifactId>
<version>1.0</version>
</parent>
<dependencies>
<dependency>
<groupId>framework_snt</groupId>
<artifactId>SFP</artifactId>
<version>6.3</version>
<type>pom</type>
</dependency>
</dependencies>
</project>
我怎么设置的Maven这样的构建将使用儿童在失败模块上面,但是当我删除标签<version>6.3</version>
它成功了(或者我改变了版本以匹配顶级pom的版本?
该框架是否属于贵公司?你可以通过nexus设置一个块吗? – 2012-02-22 21:05:15
是的框架是我公司内部的。在nexus中设置模块不会有效,原因有二:1)我们使用artifactory,2)我需要使用这个概念不仅仅是内部框架版本。 – Jon 2012-02-25 01:02:54