Our legacy Ant build uses prebuilt Eclipse loader classes in a zip file. How can I add these to a executable JAR file with the maven-jar-plugin?
This is my current plugin config:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader</mainClass>
</manifest>
<manifestEntries>
<Rsrc-Main-Class>com.xyz.GuiMain</Rsrc-Main-Class>
<Class-Path>.</Class-Path>
<Rsrc-Class-Path>./ commons-net-3.6.jar commons-io-2.6.jar</Rsrc-Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
I previously had the resources tag after the archive tag, but that did not work either. I believe we also have a constraint right now where our CodeMeter.jar needs to be embedded as a JAR within the executable JAR hence our use of the jar-in-jar-loarder.zip classes from Eclipse. When I had extracted all the jar class contents so they were directly in the executable JAR, we were running into JNI binding issues.
I also have the maven-assembly-plugin defined, but I'm not sure if it is required or doing anything:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader</mainClass>
</manifest>
<manifestEntries>
<Rsrc-Main-Class>com.xyz.GuiMain</Rsrc-Main-Class>
<Class-Path>.</Class-Path>
<Rsrc-Class-Path>./ commons-net-3.6.jar commons-io-2.6.jar CodeMeter.jar</Rsrc-Class-Path>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
It was previously done like this in Ant:
<target name="create_cli_jar" depends="clean,init,compile,build_properties" description="Build and package xyz command line utility">
<jar destfile="${dist.dir}/${cli.prefix}.jar">
<manifest>
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
<attribute name="Rsrc-Main-Class" value="com.xyz.GuiMain"/>
<attribute name="Class-Path" value="."/>
<attribute name="Rsrc-Class-Path" value="./ commons-net-3.6.jar commons-io-2.6.jar"/>
</manifest>
<fileset dir="${dist.dir}" includes="build.properties" />
<fileset dir="${classes.dir}"/>
<zipfileset src="lib/jar-in-jar-loader.zip"/>
<zipfileset dir="lib" includes="commons-net-3.6.jar"/>
<zipfileset dir="lib" includes="commons-io-2.6.jar"/>
<zipfileset dir="lib" includes="CodeMeter.jar"/>
</jar>
</target>