mvn versions:set -DnewVersion=1.0.0
There is one nuance though. In some cases, project version is inherited from parent, and project's POM uses parent POM, like this:
<parent> <groupId>com.company</groupId> <artifactId>company-parent</artifactId> <version>1.0</version> <relativePath>../company-parent/pom.xml</relativePath> </parent>
In this case for a local maven build, version does not have to be defined in POM as it will be 2.0, the version number of parent. However, the mvn versions:set command will result in error with the following message:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Project version is inherited from parent.
Thus, some version has to be added to the project. If project still has to have parent version for some reason, then just copy version from inside parent tag. Otherwise, just go with any valid version number.
Hi,
ReplyDeleteYou can avoid this error by using the maven parameter :
-N
which allow to not recurse into sub-projects.
Details here : http://stackoverflow.com/a/12494574/1628014
The reason this is happening is because you would be updating the version of 2 artifacts: the one you are specifying, plus the one that inherits for the pom you are specifying.
ReplyDeleteThus the plugin refuses to do so.
One tip to avoid this error: If you have your parent pom in a subdirectory, trying changing directories before you run the 'mvn versions:set' command.
So suppose you have your parent pom in ./parent/pom.xml.
Then run the command:
cd parent
mvn versions:set -DgroupId=org.mycompany.myprogram -DartifactId=org.mycompany.myprogram.parent -DnewVersion=1.0.92-SNAPSHOT -DgenerateBackupPoms=false