maven-enforcer-plugin
を使用していくつかの依存関係を禁止できます。
ここには、Apache Commons Loggingを除外した例があります。実行しているとき
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>enforce-banned-dependencies</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<excludes>
<exclude>commons-logging:commons-logging</exclude>
</excludes>
</bannedDependencies>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
出力mvn install
は次のようになります。
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.BannedDependencies failed with message:
Found Banned Dependency: commons-logging:commons-logging:jar:1.1.1
Use 'mvn dependency:tree' to locate the source of the banned dependencies.
それはすべてがBUILD FAILURE
で終わります。
私のもう1つのお気に入りは、コードハウスの特別なエンフォーサルールライブラリの[banDuplicateClasses](http://mojo.codehaus.org/extra-enforcer-rules/banDuplicateClasses.html)ルールです。これは、 'commons-logging'と' jcl-over-slf4j'の両方の依存関係によって導入された重複クラスを検出します。 – Ramon