<jlink compress="false" outfile="out.jar"> <mergefiles> <pathelement path="${build.dir}/mergefoo.jar"/> <pathelement path="${build.dir}/mergebar.jar"/> </mergefiles> <addfiles> <pathelement path="${build.dir}/mac.jar"/> <pathelement path="${build.dir}/pc.zip"/> </addfiles> </jlink>Non-deprecated alternative to the above:
<jar compress="false" destfile="out.jar"> <zipgroupfileset dir="${build.dir}"> <include name="mergefoo.jar"/> <include name="mergebar.jar"/> </zipgroupfileset> <fileset dir="${build.dir}"> <include name="mac.jar"/> <include name="pc.jar"/> </fileset> </jar>Suppose the file foo.jar contains two entries: bar.class and barnone/myClass.zip. Suppose the path for file foo.jar is build/tempbuild/foo.jar. The following example will provide the entry tempbuild/foo.jar in the out.jar.
<jlink compress="false" outfile="out.jar"> <mergefiles> <pathelement path="build/tempbuild"/> </mergefiles> </jlink>However, the next example would result in two top-level entries in out.jar, namely bar.class and barnone/myClass.zip
<jlink compress="false" outfile="out.jar"> <mergefiles> <pathelement path="build/tempbuild/foo.jar"/> </mergefiles> </jlink>