Reputation: 4270
I'd like to create like a "fat" jar with ant where I have, not only the usual classes, manifest files, etc, but also my 'libs' folder too.
I tried with:
<jar destfile="myjar.jar" update="yes" basedir="${libs.dir}"/>
but this adds the files in 'libs' the root of the jar file where I'd like to have the libs folder itself in the jar (with everything it contains of course)
Can I maybe create the lib folder myself in the jar and add the files to that specific location in the jar then ?
Upvotes: 3
Views: 17230
Reputation: 776
If you specify to use the directory as the root for your file set then you can just match for the directory and it will preserve the structure.
<jar destfile="myjar.jar" >
<fileset dir=".">
<include name="**/${libs.dir}/**"/>
</fileset>
</jar>
Upvotes: 9
Reputation: 34652
You have to do something like the following. Specifically, the zipfileset command. You basically are saying you want to build the ${build.name}.jar (you could hard code a path to be "myjar.jar" or something along those lines) and then add the various files to the JAR.
Hope this helps!
<jar destfile="${dist}/${build.name}.jar">
<!-- Generate the MANIFEST.MF file. -->
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Release-Version" value="${version}" />
<attribute name="Main-Class" value="my.lib.Main" />
<attribute name="SplashScreen-Image" value="TitleScreen.png" />
<attribute name="Class-Path" value="${classpath}" />
</manifest>
<zipfileset dir="${build.dir}" />
<zipfileset dir="${resources}" />
<fileset file="${resources}/icons/misc_icons/TitleScreen.png" />
</jar>
Upvotes: 2
Reputation: 24788
Use this ant extension: http://one-jar.sourceforge.net/
There is also Eclipse plugin: FatJar
Upvotes: 1