| ----- |
| Cookbook - How To Add SVN Revision To A JAR Manifest |
| ----- |
| Vincent Siveton |
| ----- |
| January 2008 |
| ----- |
| |
| Cookbook: How To Add SVN Revision To A JAR Manifest? |
| |
| * Summary |
| |
| This recipe describes how to add SVN revision to a JAR manifest. |
| |
| * Prerequisite Plugins |
| |
| Here is the list of the plugins used: |
| |
| *-----------------------------------------------------------+--------------+ |
| || <<Plugin>> || <<Version>> |
| *-----------------------------------------------------------+--------------+ |
| | {{{../../plugins/maven-jar-plugin/} <<<jar>>>}} | 2.2 |
| *-----------------------------------------------------------+--------------+ |
| | {{{http://mojo.codehaus.org/buildnumber-maven-plugin/} <<<buildnumber>>>}} | 1.0-beta-1 |
| *-----------------------------------------------------------+--------------+ |
| |
| * Sample Generated Manifest |
| |
| +-----+ |
| Manifest-Version: 1.0 |
| Archiver-Version: Plexus Archiver |
| Created-By: Apache Maven |
| Built-By: vsiveton |
| Build-Jdk: 1.5.0_12 |
| SCM-Revision: 613393 |
| +-----+ |
| |
| * Recipe |
| |
| ** Configuring Mojo Buildnumber Plugin |
| |
| We configure this plugin as suggested in the {{{http://mojo.codehaus.org/buildnumber-maven-plugin/usage.html}Mojo Buildnumber Plugin usage}} page. |
| |
| %{snippet|id=buildnumber|url=http://svn.apache.org/repos/asf/maven/sandbox/trunk/site/cookbook/generate-svn-revision/pom.xml} |
| |
| ** Configuring Maven Jar Plugin |
| |
| The last configuration is to customize the default Manifest with a new entry for the SCM revision. |
| |
| %{snippet|id=jar|url=http://svn.apache.org/repos/asf/maven/sandbox/trunk/site/cookbook/generate-svn-revision/pom.xml} |
| |
| ** Running Maven |
| |
| Just call Maven to generate the package: |
| |
| +-----+ |
| mvn package |
| +-----+ |
| |
| <<Note>>: You need to have committed your project into SVN. |
| |
| * Other Tips |
| |
| You could tweak the Jar Plugin configuration into the War Plugin. |
| |
| * Resources |
| |
| * Source code: {{{http://svn.apache.org/repos/asf/maven/sandbox/trunk/site/cookbook/generate-svn-revision}http://svn.apache.org/repos/asf/maven/sandbox/trunk/site/cookbook/generate-svn-revision}} |
| |
| * {{{../../plugins/maven-jar-plugin/} Maven Jar Plugin}} |
| |
| * {{{http://mojo.codehaus.org/buildnumber-maven-plugin/} Mojo Buildnumber Maven Plugin}} |
| |
| [] |