This rule checks the dependencies and fails if any of the matching excludes are found.
The following parameters are supported by this rule:
For example, to ban all xerces except xerces-api you would exclude "xerces" (groupId) and include "xerces:xerces-api"
Sample Plugin Configuration:
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>1.4.1</version> <executions> <execution> <id>enforce-banned-dependencies</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <bannedDependencies> <excludes> <exclude>org.apache.maven</exclude> <exclude>org.apache.maven:badArtifact</exclude> <exclude>*:badArtifact</exclude> </excludes> <includes> <!--only 1.0 of badArtifact is allowed--> <include>org.apache.maven:badArtifact:1.0</include> </includes> </bannedDependencies> </rules> <fail>true</fail> </configuration> </execution> </executions> </plugin> </plugins> </build> [...] </project>
Example plugin configuration which ignores transitive dependencies:
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>1.4.1</version> <executions> <execution> <id>enforce-banned-dependencies</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <bannedDependencies> <excludes> <exclude>commons-lang:commons-lang</exclude> </excludes> <searchTransitive>false</searchTransitive> </bannedDependencies> </rules> <fail>true</fail> </configuration> </execution> </executions> </plugin> </plugins> </build> [...] </project>