A demonstration how to tag each module of a maven multimodule project.
Latest commit 9fc436a Jan 27, 2011 @mfriedenhagen Explain how it works


Using maven-release-plugin and maven-scm-plugin to tag all submodules of a multimodule project


In our company we have a policy that every released artifact should have a release tag in Subversion assuming tagging is a cheap operation in subversion.

So given a standard multimodule project:

foo/trunk/pom.xml (groupId=foo,artifactId=parent,version=1.0-SNAPSHOT)

I want to have the following tags after running mvn -B release:prepare release:perform


Each tag should contain the full trunk.

Let's say we deploy app1-1.8 and now want to fix a bug in this app. If we always copy the *whole trunk* beneath a tag called app1-1.8, we just have to checkout this tag and do not need to know, that version 1.8 of app1 is found in SVN beneath a tag called parent-1.8.

It is our policy that all components beneath a common trunk are strongly coupled and should all be released newly if something changes beneath it. We have used this scheme for a couple of years now, not only with maven but with C++ and Python projects as well, where one Makefile could produce several RPMs and implemented automated checks for getting postings to a newsgroup with the last QA notes from the former release and doing a quick gatekeeper code review in our QA team examining the diff between the last releases to make sure hotfixes do really only fix the hot issue(s) :-).

How it works

  • First of all you need to configure the maven-release-plugin in your parent pom.xml to use an additional releaseProfile.
  • In this profile you configure the maven-scm-plugin depending on your SCM.
  • In your submodules, make sure to include the maven-scm-plugin in the build section.
  • For SVN you need to make sure, that your submodules use the same URLs as the parent project, otherwise not the trunk but only the submodule will be tagged.

How to use this example with SVN

  • You need Maven 3 to get this running, there is still an issue with Maven2 during deployment with this pom.
  • Check out the repository. Remove the .git directory, it is not needed.
  • Create a local subversion repository beneath svnadmin create /Software/nobackup/svnrepo/.
  • Create the needed sub directories:
    • svn mkdir -m 'Initial' file:///Software/nobackup/svnrepo/multimodule/
    • svn mkdir -m 'Initial' file:///Software/nobackup/svnrepo/multimodule/releases
  • Import the project: svn import -m'Initial' . file:///Software/nobackup/svnrepo/multimodule/trunk
  • Checkout the project into another location: svn co file:///Software/nobackup/svnrepo/multimodule/trunk /tmp/multi-module-svn/
  • Switch to /tmp/multi-module-svn/
  • Adapt the distributionManagement section.
  • Commit your changes.
  • Run mvn clean deploy to deploy a SNAPSHOT.
  • Run mvn -B release:prepare release:perform.

How to use this example with GIT

  • Check out the repository to ${user.home}/Documents/workspace/multimodule.
  • Switch to git branch: git checkout git
  • Adapt the distributionManagement section.
  • Commit your changes.
  • Run mvn clean deploy to deploy a SNAPSHOT.
  • Run mvn -B release:prepare release:perform.