While developing an applet, I created a maven project with .jar packaging and different .jar dependencies. Now I want to add an archive index (/META-INF/INDEX.LIST) to my project’s jar that contains not only the entries for this jar but also the entries of all dependency jar’s.
With the jar command line tool I’d achieve it with
> jar i myproject.jar dependency1.jar dependency2.jar …
Using the maven archive index flag of the maven-jar-plugin only the entries for myproject.jar occur in the archive index, not so the entries of the dependency jars:
...
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<index>true</index>
</archive>
</configuration>
</plugin>
...
Is there a possibility to include the entries of dependencies into the index file with maven?
Thank you for any hints…
I finally solved it with the following configuration:
With this configuration, all jar files (project and dependencies) are listed in the MANIFEST.MF’s classpath and their entries (files at directory level and package names according to the jar index doc) will occur in INDEX.LIST.
Note #1: Using both index and addManifest prior version 2.4 results in the bug described in http://jira.codehaus.org/browse/MJAR-69. So make sure to use version 2.4 of the maven-jar-plugin.
Note #2: Due to the bug described in http://jira.codehaus.org/browse/MNGECLIPSE-1219, dependencies will occur neither in MANIFEST.MF nor in INDEX.LIST if dependencies are resolved using Resolve Workspace artifacts (option of the Eclipse Run configuration). So make sure that you a) first install/deploy all dependencies and b) disable the Resolve Workspace artifacts option (or close the dependency project in eclipse) if necessary before building the project with eclipse.
Note #3: Do NOT use both the jar-with-dependencies (maven-assembly-plugin) and addClasspath (maven-jar-plugin), or you’ll double all entries in the resulting jar.
Note #4: The java jar command line tool does also evaluate the MANIFEST.MF’s classpath (besides explicit listing of jar files when invoking the tool as shown in my initial example), see the index example of the jar doc.
Due to Note #2, I’ll investigate into ANT’s jar…
Many thanks to @khmarbaise pointing my to the right direction 🙂