7

I love using Maven and distributed SCMs like Mercurial (BitBucket).

However as I bring my project to scale and my Hg repository grows, I am finding the Maven Release plugin more and more cumbersome to work with.

The primary problem is that when a mvn release:prepare is called Maven doesn't take advantage of the distributed nature of Hg and performs a full clone of the entire repository to put into a temporary directory.

The issue is very well documented by Fabrizio Giudici back in 2009 http://weblogs.java.net/blog/fabriziogiudici/archive/2009/10/29/fixing-two-problems-maven-mercurial-hudson

I would have thought Sonatype might have updated the plugin by now, but alas we are still having to download the entire repo prior to releasing.

I was hoping to reach out to the StackOverflow community to see if anyone else was experiencing this problem and whether anybody has come up with novel ways of solving the dreaded full clone upon a maven release.

2
  • How large is your hg repository?
    – khmarbaise
    Aug 2, 2012 at 10:44
  • It's not too big, but I can see problems coming up later on. It is around 50mbs at the moment
    – alwinc
    Aug 8, 2012 at 0:32

1 Answer 1

14

This is what I do to avoid the silly multi push to mercurial with maven:

First make sure you use the correct version of the plugin handling the mercurial type of scm via:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <tagNameFormat>@{project.version}</tagNameFormat>
    </configuration>
</plugin>

then execute first the prepare goal

mvn release:prepare -DautoVersionSubmodules=true -DreleaseVersion=x.x.x -DdevelopmentVersion=y.y.y-SNAPSHOT -DpushChanges=false

note the pushChanges=false attribute

if all ok then
    hg push
    mvn release:perform
else
    mvn release:clean
    and have fun removing the changeset from local hg repo
endif
5
  • Hey Farid, nice one... haven't tried it yet but the flag looks promising. The code below... is that supposed to be pseudo code you suggest I execute according to what happens?
    – alwinc
    Aug 10, 2012 at 2:10
  • yes it's pseudo, but you could handle it with any scripting tools (dos, shell,...) using the return error code of maven
    – Farid
    Aug 10, 2012 at 8:17
  • hiya, don't forget to accept the answer if it answers the request.
    – Farid
    Aug 16, 2012 at 16:29
  • Is there any reason for fun when removing the local changeset in case of an error? Shouldn't a "hg rollback" suffice? Feb 5, 2013 at 3:58
  • in most of the cases yes, a hg rollback would be enought, with maybe some slight manual file deletion.
    – Farid
    Feb 5, 2013 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.