Previously I used below command to take the version in pom.xml and increment it from one. Before increment snapshot version is, 0.0.1
#!/bin/bas
The simple solution to set the version to a particular value via versions-maven-plugin
mvn versions:set -DnewVersions=0.0.1
If you like to increment it. This could be achieved by using by build-helper-maven-pugin like the following:
mvn build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.nextMajorVersion}.0.0 \
versions:commit
or if you like to increment the minor version:
mvn build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 \
versions:commit
or if you like to increment the patch version:
mvn build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} \
versions:commit
You need to pay attention to quoting which is needed on Windows/Linux.
or you can use maven-release-plugin which will increment the current version to the next one by just calling:
mvn -B release:update-versions
Or you you the maven-release-plugin via the usual release process by mvn release:prepare release:perform which by default increments the version also.