Avisi Blog

Maven release plugin and scm / git version

Geschreven door Gert-Jan van de Streek | 21 July 2014

For a while I have been wrestling with Maven in the release:prepare release:perform cycle. The problem: Maven builds the right release in the target directory, but uploads a SNAPSHOT to Nexus or Artifactory. This apparently has something to do with newer versions of git (I'm on 2.0.1). Just in case you run into the same problem, here's what worked for me:

 

If you are running Maven 3.2.2 (latest at the time of writing), the super pom depends on release plugin version 2.3.2, which in turn depends on scm version 1.7. You need a newer version of the git provider (1.9) that fixes that SNAPSHOT problem:

In your pom.xml, explicitly depend on a specific version of the scm git provider:


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

 

An alternative is to use the jgit provider, something I haven't tried myself.

Hope this helps. If you can enlighten me on the specifics of maven.scm.version, I'm all ear. It confuses me quite a bit.

 

Bonus material

While trying to find a solution to the problem, I used some Maven magick I never ever had to use before (and honestly, wish I never had):

 

mvn release:rollback

 

This basically reverts all the changes to your pom.xml and deletes the temporary files maven created for it (release.properties and pom.xml.releaseBackup).

 

What release:rollback does not do for you is delete the tags, you can use the following commands for that:

 

delete the local git tag:

git tag -d yourtag

delete the remote git tag:

git push origin :refs/tags/yourtag