Fork me on GitHub

Ban Circular Dependencies

This rule checks the dependencies and fails if the groupId:artifactId combination exists in the list of direct or transitive dependencies.

Note that this rule is of no use for Maven 2. It is only useful if you use or plan to use Maven 3. (For more information about this, see this thread.)

Sample Plugin Configuration:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.0</version> <!-- find the latest version at http://maven.apache.org/plugins/maven-enforcer-plugin/ -->
        <executions>
          <execution>
            <id>enforce-ban-circular-dependencies</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <banCircularDependencies/>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>1.0-beta-6</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

Trademarks

Apache, Apache Maven, Maven and the Apache feather logo are trademarks of The Apache Software Foundation.