When using the maven-jar-plugin
I would like to add entry to the Manifest.mf
So it will contain:
Class-Path: .
When i add this entry to the Pom:
<Class-Path>.</Class-Path>
It will create Class-Path with all dependency
Like:
Class-Path: . jar1name.jar jar2name.jar etc
Instead of just
Class-Path: .
Is there a way to avoid maven from adding all jar names to the Class-Path?
Thanks
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Built-By>Me</Built-By>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
Maven Archiver can add the classpath of your project to the manifest. This is done with the <addClasspath> configuration element.
Maven creates this classpath by considering the project's dependencies. The reported classpath consists of references to JAR files cached in local Maven repository. Even the JAR artifact of the project is referenced from local Maven cache and not from the /target directory one or the other might expect.
Plugins are the central feature of Maven that allow for the reuse of common build logic across multiple projects. They do this by executing an "action" (i.e. creating a WAR file or compiling unit tests) in the context of a project's description - the Project Object Model (POM).
This did the trick
Omitting the addClasspath and adding manifestEntries
Now, log4j.properties can reside outside the jar - and still be found...
<manifest>
<addClasspath>true</addClasspath>
</manifest>
This is working:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Built-By>Me</Built-By>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
Output:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Build-Jdk: 1.6.0_45
Built-By: Me
Class-Path: .
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