Skip to content
𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

Updating version in all pom.xml files of a project

Posted on April 17, 2022May 17, 2024 By sastrija

When you have a multi project configuration for your maven based application, manually updating the project version after each release is not that easy. There will be at least 2 references to the project version number and it will give unexpected error if you forget to update version for one child project dependency.

We can update the version number easily by using below command.

mvn build-helper:parse-version versions:set-DnewVersion=${parsedVersion.majorVersion).$(parsedVersion.minorVersion}.$(parsedVersion.nextIncrementalVersion}-${parsedVersion qualifier} -DgenerateBackupPoms=false

Above command will work only if your project version is in MAJOR.MINOR.INCREMENTAL-QUALIFIER format. e.g., 0.0.1-SNAPSHOT.

If your project version doesn’t contain qualifier (e.g., 0.0.1), use below command.

mvn build-helper:parse-version versions:set-DnewVersion=${parsedVersion.majorVersion).$(parsedVersion.minorVersion}.$(parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false

Use of scripts from command prompt

Typing this long command all the time is not easy and it is a good idea to store this as a DOS/UNIX script. If you are using windows OS, make sure you have a bin folder configured in your system. If not already done, refer https://sastrija.com/configuring-bin-folder-in-windows-os/ for more details. In my case, I’ve saved this script as update.bat in my Windows system.

Once the script is created, open the parent project folder in command prompt and enter update command. This will update the version in all pom.xml files for the project.

Use of script from Eclipse/STS

Running this command from Eclipse/STS is more easy.

  1. Right click parent project from Project Explorer and select Show In > Terminal
  2. Type update and enter. This will update the version in all pom.xml. Here I assume you have named the script name as update.bat.

Related

Java/J2EE Maven Spring Boot Windows OS CommandsJ2EEJavaMavenSpring BootUnix ScriptWindows Script

Post navigation

Previous post
©2025 𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ | WordPress Theme by SuperbThemes