Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netbeans - adding resource files to jar file with Ant

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?

like image 322
Alistair Collins Avatar asked Dec 16 '22 20:12

Alistair Collins


1 Answers

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.

like image 152
Alistair Collins Avatar answered Dec 19 '22 09:12

Alistair Collins