I'd like to add an Implementation-Version line to a manifest in my jar file that reflects the POM version number. I can't for the life of me work out how to do this using the jar plugin.
Is this possible?
To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest. Warning: The text file from which you are creating the manifest must end with a new line or carriage return.
The manifest file is named MANIFEST. MF and is located under the META-INF directory in the JAR. It's simply a list of key and value pairs, called headers or attributes, grouped into sections.
The Default Manifest. The default contents of the manifest is described in the documentation for Maven Archiver. Starting with version 2.1, the maven-jar-plugin uses Maven Archiver 3.2.0. This means that it no longer creates the Specification and Implementation details in the manifest by default.
Starting with version 2.1, the maven-jar-plugin uses Maven Archiver 3.5.2. This means that it no longer creates the Specification and Implementation details in the manifest by default. If you want them you have to say so explicitly in your plugin configuration.
The manifest file is named MANIFEST.MF and is located under the META-INF directory in the JAR. It's simply a list of key and value pairs, called headers or attributes, grouped into sections. These headers supply metadata that help us describe aspects of our JAR such as the versions of packages, what application class to execute, the classpath, ...
Starting with version 2.1, the maven-jar-plugin uses Maven Archiver 3.5.2. This means that it no longer creates the Specification and Implementation details in the manifest by default.
You would use the Maven Archiver:
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> </archive> </configuration> </plugin> </plugins>
This will add the following to the manifest file:
Implementation-Title: ${pom.name} Implementation-Version: ${pom.version} Implementation-Vendor-Id: ${pom.groupId} Implementation-Vendor: ${pom.organization.name}
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