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