I am creating a manifest file for my java jar via following pom.xml directives:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>parser.BulkParser</mainClass>
<classpathPrefix>dependency/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
this results in following kind of manifest to be generated:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: shaashis
Build-Jdk: 1.6.0_21
Main-Class: parser.BulkParser
Class-Path: dependency/commons-configuration-1.6.jar dependency/commons-collections-3.2.1.jar dependency/commons-lang-2.4.jar
Here I want to add a string of following type in the Class-Path:
Class-Path: conf/ dependency/commons-configuration-1.6.jar dependency/commons-collections-3.2.1.jar dependency/commons-lang-2.4.jar
How can I do that via my pom.xml?
thanks
Ashish
Altering The Classpath: Using a Custom Classpath Format is the way to go.
Edit: The above does not exactly what is desired. I have found a way to achive that by examining the Archiver source code. This will do (just verified in the shell):
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Class-Path>conf/</Class-Path>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
Modified my pom.xml as follows to get the correct solution to my problem:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>parser.BulkParser</mainClass>
<classpathPrefix>dependency/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>conf/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
this resulted in generating the value of 'Class-Path' in the manifest file as I wanted.
References:
Manifest Entries
Maven Archiver
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