How to add a version number to your hudson-built maven jar

Maven’s jar plugin will automatically add a “pom.properties” in your jar’s META-INF/maven/$groupId/$artifactId directory. If you build with hudson, there are a number of other values that you might want to include automatically, though, like the SVN revision number that the artifact was built from, and when it was built.

Here’s the configuration for the maven-jar-plugin that adds a couple of the more-interesting hudson variables to your module’s jar’s META-INF/MANIFEST.MF:

The Maven Guide to Working with Manifests and Maven Archiver pages, along with the other hudson variables may prove helpful.

Update December 14, 2009:

Note that Hudson’s SVN_REVISION macro is empty if you build your project as a maven multi-module.

Tagged with: ,
Posted in Technical HOWTOs
  • Trenton

    And to see your handiwork:

    % unzip -p mymodule-1.0-SNAPSHOT.jar META-INF/MANIFEST.MF

    Manifest-Version: 1.0
    Archiver-Version: Plexus Archiver
    Created-By: Apache Maven
    Built-By: hudson
    Build-Jdk: 1.5.0_18
    Build-Id: 2009-07-27_14-57-00
    Build-Number: 16
    Build-Tag: hudson-mymodule-16
    Hudson-Build-Number: 16
    Hudson-Project: mymodule
    Hudson-Version: 1.316
    Svn-Revision: 47689

  • andrius