I want add some resource files (non-code text-based files) to the jar file in a Java project using Netbeans 6.9, I'd expect using Ant. I had thought that this would be reasonably simple...but after quite a bit of searching I can't find how to do it..! Any pointers in the right direction?
The answer I think I was looking for is as follows:
In the build.xml file (as per trashgod's answer) you can use the hooks already in the ant build script to add the following:
<target name="-post-jar">
<echo>Adding files to jar...</echo>
<jar destfile="dist/jarFileName.jar" update="true">
<fileset dir="${basedir}">
<include name="files/*"/>
</fileset>
</jar>
</target>
This adds the files directory and any files under it directly to the jar file.
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