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.
Maven local repository is located in your local system. It is created by the maven when you run any maven command. By default, maven local repository is %USER_HOME%/. m2 directory.
mvn dependency:tree Command The main purpose of the dependency:tree goal is to display in form of a tree view all the dependencies of a given project. As we can see, maven prints the dependencies tree of our project.
A project's dependency tree can be filtered to locate specific dependencies. For example, to find out why Velocity is being used by the Maven Dependency Plugin, we can execute the following in the project's directory: mvn dependency:tree -Dincludes=velocity:velocity.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With