Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add an Implementation-Version value to a jar manifest using Maven?

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?

like image 536
izb Avatar asked May 28 '09 15:05

izb


People also ask

How do I edit a JAR file manifest?

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.

Where do I put manifest file in jar?

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.

What is the default manifest for Maven jar?

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.

What happened to the specification and implementation details in Maven-jar-plugin?

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.

What is a manifest file in a JAR file?

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, ...

What version of Maven archiver does the Maven-jar-plugin use?

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.


1 Answers

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} 
like image 188
Ascalonian Avatar answered Sep 23 '22 18:09

Ascalonian