8

In my src folder there is another folder called data which contains files data1.txt and data2.txt. The application loads a graph from these files in the initialization, so I want to include these files in my final jar. I use Ant to produce the jar file.

martin clayton
  • 76,436
  • 32
  • 213
  • 198
topless
  • 8,069
  • 11
  • 57
  • 86

2 Answers2

7

Example from http://ant.apache.org/manual/Tasks/jar.html :

  <jar destfile="${dist}/lib/app.jar">
    <fileset dir="${build}/classes"/>
    <fileset dir="${src}/resources"/>
  </jar>

So basically you would want to include the data-files in the same way as "resources" are included above.

From the documentation of the <jar> task:

It is possible to refine the set of files that are being jarred. This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes attributes.

martin clayton
  • 76,436
  • 32
  • 213
  • 198
aioobe
  • 413,195
  • 112
  • 811
  • 826
0

Copy the files to your classes directory, where they will be included into the jar.

enter code here

<target name="copyHibernateXml">
    <copy todir="classes">
        <fileset dir="${basedir}/${sourceDir}" includes="*.xml,*.csv"/>
    </copy>
</target>
pikknz
  • 19
  • 1