Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put maven project version in war file manifest?

I need to have Maven insert the version number from the POM file into the manifest located in the WAR file under /WEB-INF/manifest.mf.

How do I do this? I was able to easily file documentation for doing this in a JAR file using the maven-jar-plugin, but that does not work on a WAR file.

Thanks for the help!

like image 743
Matthew Kubicina Avatar asked Apr 25 '11 16:04

Matthew Kubicina


People also ask

What is manifest MF in war?

manifest.mf carries attributes of the artifact. One of the most well known ones is for example the main class of the jar that is used to start the jar file when no other class is specified. Syntax: Main-Class: classname. Other purposes are, for example, package sealing and package versioning.


1 Answers

Figured it out using the maven-war-plugin. See the configuration below:

<plugin>      <groupId>org.apache.maven.plugins</groupId>      <artifactId>maven-war-plugin</artifactId>      <version>2.1.1</version>      <configuration>          <archive>              <manifestEntries>                  <version>${project.version}</version>              </manifestEntries>          </archive>      </configuration> </plugin> 
like image 87
Matthew Kubicina Avatar answered Sep 20 '22 04:09

Matthew Kubicina