Maven is being used to build WCB's from source code. As a good developer, you are using a source control management system (SCM, also known as version control system) to keep track of your source code. (You are using a version control system, right?!?)
Maven can help you tagging your WCB releases properly. This document describes how to get Maven working with Subversion, although the instructions can be tweaked to work with any source control mechanism.
Usually you have a file structure like below in your repository:
Maven can be instructed to automatically create a new release tag, increase the version number in the trunk and commit the changes.
Get the right tools
In order for Maven to work with Subversion, it needs access to command line clients. If you are using TortoiseSVN, this means you need to install the command line client "svn". You can get this from http://subversion.tigris.org/getting.html#windows.
Change the pom.xml
First of all, the version in your trunk is expected to be named as "-SNAPSHOT". This only makes sense; it is not an official release.
So change your pom.xml to read:
Next, make your SCM known to Maven by adding the information to the pom.xml:
Last, configure the release plugin to let Maven know where to tag releases. Add this bit of text to the build plugins section of the pom.xml:
Note that the <tagBase> is almost the same as the <developerConnection>, but it is missing the "scm:svn:" prefix and has "/tags" at the end instead of "/trunk".
Preparing the release
Now that the pom.xml contains all instructions for Maven, you can prepare and perform the release:
If you are using an alternative "settings.xml", you will have to make sure the arguments are passed on to forked Maven processes:
Maven will ask for some input; it is safe to press "Enter" and accept the defaults.
If all goes well, a new tag will be created in the "tags" directory, which you can check by doing "svn update" in that directory.
Also, a few extra files will have been created after the "release:prepare":
Performing the release
Now that the release has been prepared, it can be performed. This will build the WCB, remove the extra files that have been created and put release files in the target directory.
If you are using an alternative "settings.xml", you will have to make sure the arguments are passed on to forked Maven processes:
Or, if you want to make a specific release:
After the build, the directory will look like:
In effect, Maven has created new release files and has tagged the release properly.
Troubleshooting
SCM not working
The SCM URL that you are using in the "pom.xml" file for "<connection>", "<developerConnection>", "<url>" and "<tagBase>" must match the one that is used on disk exactly, or you will get errors.
If you are using TortoiseSVN, you can right click on the directory and examine the SVN URL. Is the URL using the same host name and the same path?
If there is a difference, either edit the "pom.xml" or use "svn switch" to align the directory with the "pom.xml".
For example, let's assume the following:
- the directory is using "svn+ssh://user@subversion.test.com/projects/testpresentation/trunk",
- the "pom.xml" is using "svn+ssh://subversion.test.com/projects/testpresentation/trunk"
In this case, editing the "pom.xml" is not preferred as it is correctly using a general URL instead of a user-specific one. So you will want to use "svn switch" to correct the local directory as follows:
Doing release:prepare twice
If you want to do the "release:prepare" again, you can use the command below to ignore the created files:
Alternatively, you can clean up the files from a previous "release:prepare" yourself:
Missing Maven plugins
You may be missing Maven plugins, which you will notice from errors like this:
As Maven notes: the system is offline. The cause lies in your "settings.xml", which instructs Maven to work offline. Make sure you set <offline> to "false", which will enable Maven to automatically download necessary plugins:
Missing command line arguments
It is possible that the arguments on the command line are not automatically passed to forked instances of Maven. You can recognize forked instances by multiple "[INFO]" statements on the same line. This is the case in the example above, as can be seen by the "[INFO] [ERROR] BUILD ERROR" message.
To force the passing of commandline arguments to forked instances, you can use '-Darguments="..."', e.g.:
