How to put maven project version in war file manifest?

Matthew Kubicina picture Matthew Kubicina · Apr 25, 2011 · Viewed 22.3k times · Source

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!

Answer

Matthew Kubicina picture Matthew Kubicina · Apr 26, 2011

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>