Skip to main content

Subversion, Maven and the Release plugin

Posted by johnsmart on December 18, 2008 at 2:47 PM PST

There is a known bug related to Subversion clients and the Maven Release plugin that can take some time to resolve if you aren't aware of it. Sometimes, when you run the mvn release:prepare operation, you will get a strange Subversion error saying that a file already exists in the repository. This can be either because the release tag _has_ already been created (usually due to human error, such as messing up the version numbers in the POM files), or because of an obscure Subverion bug. The main symptom of this issue is that Subversion claims that a file (any file) already exists in the Subversion repository:

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Unable to tag SCM
Provider message:
The svn tag command failed.
Command output:
svn: Commit failed (details follow):
svn: File '/repos/test_repo/ci_test_project/tags/ci_test_project-1.5.24/bin/' already exists

If this occurs, you simply need to run svn update and then mvn release:prepare again.

Now the beauty of the Maven Release Plugin is that you can automate the whole bump-up-the-version-numbers-and-create-a-new-Subversion-tag-and-deploy-to-Nexus business. The obvious next step is to place this task on your trusty CI server. However, if you come across this error, you're stuck, as the build will effectively fail. Even if you use the Maven scm:update goal systematically beforehand, manually or by binding it to a particular lifecycle phase, you still come across the problem.

One simple albeit unelegent work-around is to write a simple script to handle the error, as shown here:

$MAVEN release:prepare --batch-mode
if [ $? -ne 0 ] ; then svn up && $MAVEN release:prepare --batch-mode ; fi
$MAVEN release:perform

If the release:prepare operation fails, then update and try again. If it's a real problem, it will fail again anyway. Otherwise, you're good! A scripting pro could probably do something nicer, but that's the core of it. Simple but functional!

"Best development course I have been on in a very long time...Greatly enjoyed the course...A 'must' course for serious Java developers..." - Read what people are saying about the Java Power Tools Bootcamps.


Hi. A bug fix is now available with the maven release plugin. See

I do not know why this does not work with multi modules (other users complain about this - see the maven bug entry), at least on Win32 OS. I've used the same workaround as yours for a while, but recently, when I switched some of my projects to multi modules, this does not work anymore. Even with a fresh checkout. That's why i currently use svn 1.5.0

Thanks for these precisions. Hmmm, I first used this on a multi-module project. The only issue I had with using the release plugin on multi-module projects was making sure that the main aggregator project was in the root directory (it doesn't have to be, but the release plugin seems to expect it to be there). Other than that, it worked...I'd be curious to know under what conditions this work-around doesn't work.

This is a svn bug that affects svn 1.5.1+ versions (at least to 1.5.6 version) I found the following bug in their database: svn bug: maven bug: The workaround presented in your blog does not work with multi modules project ; use svn 1.5.0 as workaround.

Yes, I think I found the bug referenced somewhere in their database. Another alternative that I'm playing around with is to use Groovy scripts rather than shell scripts - more portable and more natural for a Java coder ;-).

Yeah thanks! Used several hours trying to solve this issue yesterday! Do you know if this defect is tracked by the Subversion guys?

Thanks for the tip, real frustratingly error. Same behavior with the current latest & greatest svnsilk version (v1.5.5 )

I've had problems with running mvn release under cygwin (no problems on a unix box). Fix was to use the dreaded DOS shell. That's a shame as I love this plugin, makes releasing a breeze.

Thanks for the tip!