mavenmaven-release-pluginversions-maven-plugin

Maven check that all dependencies have been released


As part of my release process, I use mvn versions:use-releases goal to replace all -SNAPSHOT dependencies with released versions. After this, I want to check if all the SNAPSHOT dependencies have been replaced with releases or not.

Question: How can I check it?

I know, the maven release plugin performs such a check as part of release-prepare goal, but I don't want to use release plugin.


Solution

  • You can use the maven-enforcer-plugin to double check whether any SNAPSHOT dependency is still there or not.

    From the official example of its requireReleaseDeps rule:

    <project>
      [...]
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>1.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>
    

    Note the fail element set to true, in this case the build would fail if any SNAPSHOT dependency was found.

    You could place such configuration in a maven profile and activate it when required (hence whenever this check must be performed).