Quantcast
Channel: Planet Apache
Viewing all articles
Browse latest Browse all 9364

Matthias Wessendorf: How-to add the Maven version number to the MANIFEST.MF file?

$
0
0

For the Apache MyFaces Trinidad project I wanted to include the Maven version number, into the MANIFEST.MF

The solution itself is pretty straightforward. You can use an existing plugin, to get the version number. The inclusion to the MANIFEST.MF is done with one of the packaging plugins (e.g. maven-jar-plugin).

Add the following to your pom.xml file, to integrate the build-helper-maven-plugin:

...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
  <executions>
    <execution>
      <phase>validate</phase>
      <goals>
        <goal>maven-version</goal>
      </goals>
    </execution>
  </executions>
</plugin>
...

Now you can include the version information in to the generated MANIFEST.MF file. For that, just add the $maven.version variable to the manifestEntries section of your maven-jar-plugin:

...
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <configuration>
    <archive>
      <manifestEntries>
        <Maven-Version>${maven.version}</Maven-Version>
        ...
      </manifestEntries>
    </archive>
...

That’s all you need!



Viewing all articles
Browse latest Browse all 9364

Trending Articles