Require Release Dependencies

This rule checks the dependencies and fails if any snapshots are found.

The following parameters are supported by this rule:

  • searchTransitive - if transitive dependencies should be checked. Default: true
  • message - an optional message to the user if the rule fails.
  • onlyWhenRelease - if this rule should only be executed when the version is a non-SNAPSHOT version. Default: false
  • failWhenParentIsSnapshot - if the parent should be checked. Default: true
  • includes - List of dependency patterns to include when checking for snapshot versions.
  • excludes - List of dependency patterns to exclude when checking for snapshot versions

The include/exclude pattern looks like groupId:artifactId:version:type:scope and supports wildcards(*).

Sample Plugin Configuration:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.4.1</version>
        <executions>
          <execution>
            <id>enforce-no-snapshots</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireReleaseDeps>
                  <message>No Snapshots Allowed!</message>
                </requireReleaseDeps>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

Includes/Excludes Plugin Configuration:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.4.1</version>
        <executions>
          <execution>
            <id>enforce-no-snapshots</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireReleaseDeps>
                  <message>No Snapshots Allowed!</message>
                  <excludes>
                    <exclude>org.apache.maven:maven-core</exclude>
                    <exclude>org.apache.maven.plugins:*</exclude>
                  </excludes>
                </requireReleaseDeps>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>