Question

Note: long question, so in essence: I wish to know how to release, via maven, a sanctified release of an existing project under my control. I use sonatype and its plugin at the moment, but their release plugin just won't let me push a SHA1 as a release. If ready-made solutions exist, I adopt them any day, provided you tell me how to modify my pom.xml, linked below

I have a Java project (available on GitHub and in use already) which I develop using Intellij IDEA 12.0.1 (community version) on Ubuntu 12.10, 64bit. The installed version of maven is the one bundled by my distribution (3.0.4).

The problem I have lies with the pom.xml of the project:

https://raw.github.com/fge/json-schema-validator/master/pom.xml

I followed SonaType's release guide. I have set up GPG, etc, all work OK. I can release using their plugin which, I surmise, is triggered by the following lines in pom.xml:

<parent>
    <groupId>org.sonatype.oss</groupId>
    <artifactId>oss-parent</artifactId>
    <version>7</version>
</parent>

However, I have several problems with this plugin (but is it really that one?):

  • it creates garbage commits, always prefixed with [mvn-release-plugin], and I don't want that;
  • it clones from the developerConnection URI each time it wants to release, which is, frankly, stupid for anyone knowing how git works (a simple fetch and SHA1 compare can detect discrepancies) -- and this behaviour is all the more annoying that my net connection is poor, to put it mildly;
  • it asks to create a tag: I don't want that, I can create it myself, thank you very much;
  • it won't even let you customize the release commit message (and I want to include a shortlog in there).

Therefore, when I am ready for a release, I go through these steps:

  1. create a tag on HEAD, called before
  2. git cherry-pick a commit (which I know the SHA1 of) which replaces, in pom.xml, all git repository URIs to a local repository of mine, which I sync as needed;
  3. at the shell prompt, let the plugin to its stuff so that the release get available "at large":

    mvn release:clean
    mvn release:prepare
    mvn release:perform
    
  4. git rebase before: get rid of the commit changing the git URIs, squash/reword etc so that the garbage commits disappear and that the release message contains a shortlog of changes instead;

  5. create the real tag;
  6. push to github.

Of course, this means that the Maven release, which I guarantee to be sound and sane, does not match the SHA1 of the equivalent version on the Github project. And I'd like to get rid of that discrepancy.

So, how do I get the Sonatype release plugin to behave? That is, how do I tell it to:

  • trust the local git repository instead of git cloneing from developerConnection,
  • not create useless commits,
  • let me customize the release message?

Or is there a better alternative which would allow me not to go through this cumbersome processs?

Details available on demand.

Was it helpful?

Solution

The release plugin is the "official" maven-release-plugin, not a special Sonatype version. Check out the docs for the prepare and perform goals, especially localCheckout, pushChanges and suppressCommitBeforeTag (although I'm not sure the last one will do what you need).

If you prepare your project manually by changing to a release version and adding a tag, you might even be able to omit release:prepare and only run release:perform -DlocalCheckout=true, which (in theory ;) would build from your tag and push those artifacts to OSSRH.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top