I have the following in my project's pom.xml which I think should display the version of Maven being used in the resulting WAR file:
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>false</addClasspath>
</manifest>
<manifestEntries>
<Build-Time>${maven.build.timestamp}</Build-Time>
<Build-Host>${agent.name}</Build-Host>
<Build-User>${user.name}</Build-User>
<Build-Maven>Maven ${maven.version}</Build-Maven>
<Build-Java>${java.version}</Build-Java>
<Build-OS>${os.name}</Build-OS>
<Build-Label>${project.version}</Build-Label>
<Build-Path>${basedir}</Build-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
...
</plugins>
...
</build>
The MANIFEST.MF that is created looks correct see below apart from the Build-Maven line in which the ${maven.version} is not substituted with the actual version number 3.0.4 in this case.
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: stocjon
Build-Jdk: 1.6.0_35
Build-Host:
Build-Java: 1.6.0_35
Build-Label: 1.0.0-SNAPSHOT
Build-Maven: Maven ${maven.version}
Build-OS: Windows XP
Build-Path: C:\Development\project_name
Build-Time: 15:38:50 21-Sep-2012
Build-User: user_name
Any ideas why Maven version is not being populated in the MANIFEST.MF ?
Help would be much appreciated.
Thanks Jon
Before moving on, we can check the default JDK version of Maven. Running the mvn -v command will show the Java version in which Maven runs.
By default, Maven Archiver creates the manifest file for you. It is sometimes useful to use your own hand crafted manifest file. Say that you want to use the manifest file src/main/resources/META-INF/MANIFEST.
The Maven Archiver is mainly used by plugins to handle packaging. The version numbers referenced in the Since column on this page are the version of the Maven Archiver component - not for any specific plugin. To see which version of Maven Archiver a plugin uses, go to the site for that plugin.
You need to add this 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>
Check here for details.
We no more need the build-helper-maven-plugin since the feature (MSHARED-38) was added to the component maven-archiver : 2.5 in Feb. 2012 (release notes).
And this component is used by the Maven plugins like maven-jar-plugin, maven-war-plugin, maven-ear-plugin, etc.
The versions of these plugins using this feature are :
So now we'll have this entry by default in the archive's manifest.mf :
Created-By: Apache Maven ${maven.version}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With