Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 895
Mikhail Chibel Avatar asked Jun 30 '16 03:06

Mikhail Chibel


People also ask

Where are the Maven dependencies are available?

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.

What will the mvn dependency tree command do?

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.

How do you analyze a dependency tree in Maven?

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.


1 Answers

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).

like image 94
A_Di-Matteo Avatar answered Oct 20 '22 02:10

A_Di-Matteo