views:

860

answers:

3

I have a multi-module project.

parent POM (1.0-SNAPSHOT)
|-- module1 (1.0-SNAPSHOT)
|-- module2 (1.0-SNAPSHOT)
`-- module3 (1.0-SNAPSHOT)

When I execute mvn release:prepare it verify that parent POM has a SNAPSHOT version and all dependent modules don't have a SNAPSHOT version. How automatically update all child modules from SNAPSHOT to the next release version?

I would like automatically increment version for all modules.

+4  A: 

The release plugin can handle that. Did you check Updating POM Versions? But... I don't get something. Changing the version in the POMs from x-SNAPSHOT to a new version and bumping the version in the POMs to a new value y-SNAPSHOT should be done by release:prepare as explained in Prepare a Release. What is going wrong when using this goal?

Update: The autoVersionSubmodules parameter might be what you're looking for. From the Prepare a Release example:

Multi-module projects

You will be prompted for the version number for each module of the project. If you prefer that every module gets the same version as the parent POM, you can set the option autoVersionSubmodules to true. Now you will be asked only once for the release version and the next development version.

Pascal Thivent
For example command mvn versions:set -DnewVersion=1.0 update the parent POM and modules versions. But I don't want to update the parent version...What is the best practices for releasing the multi-module projects?
eugenn
release:prepare require that all modules have a non-SNAPSHOT versionTherefore I should manually change versions for all modules. For instance the project consist of 15th modules. Therefore I finding a way how to update automatically all modules.
eugenn
@eugenn No, you don't have to change that manually, the `release:prepare` goal does it for you (check the link again).
Pascal Thivent
Thank you Pascal, you are right! release:prepare works well. Possible I have some configurations issues with my parent POM.
eugenn
A: 

You have also the Maven Version plugin that can help you to manage this kind of things...

romaintaz
A: 

There is a potentially better option over at http://jira.codehaus.org/browse/MNG-624?focusedCommentId=210447&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_210447

That is a workaround for the fact that you can't refer to the top level pom in the sub-module poms without having an explicit version listed. (which is what bug MNG-624 is about) It explains how you can have a single location for the version (in a top-level profiles.xml file), and simply have a property references in all the pom.xml files (i.e. ${currentVersion})

However, in this scheme release:prepare probably won't update profiles.xml for you.

Eric