Quite similar to Maven check that all dependencies have been released, Maven should also automatically check, that the version of the current version is not a SNAPSHOT.
What is the easiest way to do this?
Quite similar to Maven check that all dependencies have been released, Maven should also automatically check, that the version of the current version is not a SNAPSHOT.
What is the easiest way to do this?
It does not seem that the maven-enforcer-plugin
provides a built-in rule for this task.
Nevertheless the requireProperty
can be configured to perform the check.
I put the following snippet in my release
profile.
The first execution checks that the project version does not contain the String SNAPSHOT
.
The second execution checks that no dependency is a SNAPSHOT
version.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>enforce-property</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>project.version</property>
<message>"Project version must be specified."</message>
<regex>^(?!.*SNAPSHOT).+$</regex>
<regexMessage>"Project version must not contain -SNAPSHOT."</regexMessage>
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
<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>