Ban Distribution Management

This rule can be used to force the absence of distributionManagement in your pom files.

The following parameters are supported by this rule:

  • message - an optional message to the user if the rule fails.
  • allowRepository - You can allow repository entry (default: false).
  • allowSnapshotRepository - you can allow snapshotRepository entry (default: false).
  • allowSite - You can allow site entry (default: false).
  • ignoreParent - You can control if the parent will be checked or not (default: true).

Sample Plugin Configuration:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.4</version>
        <executions>
          <execution>
            <id>no-distribution-management-at-all</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <banDistributionManagement/>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

The above configuration will prevent any declaration of distributionManagement in your pom files except in the parent.

Let use take a look at the following project which is a typical multi-module project.

   +-- root (pom.xml)
        +-- m1 (pom.xml)
        +-- m2 (pom.xml)

Usually you should define the distributionManagement only once in your hierarchy.

company-parent (pom.xml)

+-- root (pom.xml) +-- m1 (pom.xml) +-- m2 (pom.xml)