lxs
lxs

Reputation: 9847

How do I link two Maven goals to execute before another?

We want to use mvn release:prepare to release our build. However, we also build a dependency and both builds use SNAPSHOTs.

The Maven-versions-plugin can help us deal with this, so our build process would be:

mvn versions:update-properties
mvn versions:update-parent
svn ci
mvn release:prepare

I looked into how we could link these together and the simplest way I found was to write a plugin with a custom lifecycle: http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-plugins-lifecycle.html

Please can anyone do better? At that level of complexity, I'd rather just document the three lines.

The POMs would be very lengthy, hope this helps:

Parent (has a version)
|- ParentFather
|- ParentMother

Main (parent is Parent, has a version, contains property Child.version)
|- MainBrother (depends on MainSon and ParentFather)
|- MainSister
|- MainDaughter (has version Child.version)
|- MainSon (has version Child.version)

So to release Main, which is my end-goal, I need to release Parent, Son, and Daughter. Having done that, I need to update Main to use these versions.

Upvotes: 0

Views: 248

Answers (1)

nwinkler
nwinkler

Reputation: 54507

If you want to automate it, a simple script could also help. You could even add some evaluation of the return value to make sure that the previous step didn't fail.

Have you looked into using a profile to execute the steps in that order? You could bind the versions plugin steps to an early phase of the project, and then follow with the SVN commit (use the SCM plugin) and the release.

Upvotes: 1

Related Questions