Advancing dependency versions
There are a number of goals which can be used to advance dependency versions:
- versions:use-next-releases searches the pom for all non-SNAPSHOT versions for which a newer release is available, and replaces them with the next release version.
- versions:use-latest-releases searches the pom for all non-SNAPSHOT versions for which a newer release is available, and replaces them with the latest release version.
- versions:use-next-snapshots searches the pom for all non-SNAPSHOT versions for which a newer -SNAPSHOT version is available, and replaces them with the next -SNAPSHOT version.
- versions:use-latest-snapshots searches the pom for all non-SNAPSHOT versions for which a newer -SNAPSHOT version is available, and replaces them with the latest -SNAPSHOT version.
- versions:use-next-versions searches the pom for all versions for which a newer version is available, and replaces them with the next version.
- versions:use-latest-versions searches the pom for all versions for which a newer version is available, and replaces them with the latest version.
All of these goals share a common set of parameters.
Deciding which goal to use
The following matrix should help decide which goal(s) to use:
| Goal | Modifies Release dependencies | Modifies -SNAPSHOT dependencies | Considers releases | Considers -SNAPSHOTs | Picks Next | Picks Latest |
|---|---|---|---|---|---|---|
| use-next-releases | Yes | Yes | Yes | |||
| use-latest-releases | Yes | Yes | Yes | |||
| use-next-snapshots | Yes | Yes | Yes | |||
| use-latest-snapshots | Yes | Yes | Yes | |||
| use-next-versions | Yes | Yes | Yes | If -DallowSnapshots=true | Yes | |
| use-latest-versions | Yes | Yes | Yes | If -DallowSnapshots=true | Yes |
The columns in the above goal matrix are as follows:
- Modified Release dependencies when scanning the
pom.xmlfor dependency to update, include those dependencies which are for release versions (i.e. non-SNAPSHOT versions). - Modified -SNAPSHOT dependencies when scanning the
pom.xmlfor dependency to update, include those dependencies which are for -SNAPSHOT versions. - Considers releases when building the list of newer versions of a dependency, include release versions (i.e. non-SNAPSHOT versions) in the list.
- Considers -SNAPSHOTs when building the list of newer versions of a dependency, include -SNAPSHOT versions in the list.
- Picks Next when the list of newer versions is sorted in increasing order, pick the first newer version in the list, i.e. the oldest newer version available, also known as the “next” version.
- Picks Latest when the list of newer versions is sorted in increasing order, pick the last newer version in the list, i.e. the newest version available, also known as the “latest” version.
Controlling which dependencies are processed
You can restrict which dependencies should be processed. For example, the following will only match dependencies that match the groupId “org.codehaus.plexus” and artifactId “plexus-utils”
mvn versions:use-next-releases -Dincludes=org.codehaus.plexus:plexus-utils
The includes and excludes parameters follow the format groupId:artifactId:type:classifier. Use a comma separated list to specify multiple includes. Wildcards (*) can also be used to match multiple values.
This example will match anything with the groupId “org.codehaus.plexus” and anything with the groupId and artifactId matching “junit”.
mvn versions:use-next-releases -Dincludes=org.codehaus.plexus:*,junit:junit
You can pre-configure defaults for includes and excludes in your pom.xml if there is a specific set of dependencies that you need to track on a regular basis, e.g.
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.25.3</version>
<configuration>
...
<includes>
<include>org.codehaus.plexus:*</include>
<include>junit:junit</include>
</includes>
...
<excludes>
<exclude>org.codehaus.plexus:plexus-utils</exclude>
</excludes>
...
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>
By default, both the project/dependencyManagement and project/dependencies sections will be processed. You can use the processDependencies and processDependencyManagement parameters to control which sections are processed.
This example will only process the project/dependencyManagement section of your pom:
mvn versions:use-next-releases -DprocessDependencies=false
While this example will only process the project/dependencies section of your pom:
mvn versions:use-next-releases -DprocessDependencyManagement=false
Updating plugin versions
The same goals update plugin versions when you set processPlugins. This is off by default.
mvn versions:use-latest-releases -DprocessPlugins=true
The goal updates plugins that have a version of their own in the pom, in build/plugins, build/pluginManagement and reporting, including those in profiles. It leaves alone:
- Plugins without a version, which take theirs from a parent or from Maven itself. To list them, see Checking for new plugin updates.
- Plugins whose version is held in a property. Use update-properties for those.
A plugin version that requires a newer Maven than your project does is skipped. The goal takes the project's minimum Maven from the requireMavenVersion rule of the Maven Enforcer Plugin, or from prerequisites. If the project declares neither, the goal uses the oldest Maven it runs on itself, 3.9.0.
includes and excludes apply to plugins as well, with the type maven-plugin. Without any includes, processPlugins updates every plugin with a version. To update only some plugins, name them:
mvn versions:use-latest-releases -DprocessPlugins=true -DprocessDependencies=false \
-DprocessDependencyManagement=false -Dincludes=org.apache.maven.plugins:*

