Maven How to set a new project version

Run the following command:

mvn versions:set -DnewVersion=1.0.1-SNAPSHOT

Example:

This example sets the version of the current maven project to 1.0.2. Once the pom is updated the jar generated will be using the new version number.

The output will be:

$ mvn versions:set -DnewVersion=1.0.2-SNAPSHOT
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.3:set (default-cli) @ my-app ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: V:\tmp\
[INFO] Processing change of com.mycompany.app:my-app:1.0.1-SNAPSHOT -> 1.0.2-SNAPSHOT
[INFO] Processing com.mycompany.app:my-app
[INFO]     Updating project com.mycompany.app:my-app
[INFO]         from version 1.0.1-SNAPSHOT to 1.0.2-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.952 s
[INFO] Finished at: 2020-03-01T11:14:26-08:00
[INFO] Final Memory: 17M/619M
[INFO] ------------------------------------------------------------------------

Updating the build number ensures that there is no compatibility issues when modifying the application code.

References:

Maven

Share this article:

Recent Comments