tags:

views:

3069

answers:

1

I am a bit of an ant newbie, and I'm having trouble making a jar correctly. As an example, say I want to make a jar with my StringUtil class. Using the following ant directive, I can create the jar, but the problem is that the directory structure is lost. It simply puts StringUtil.class in the base directory of the jar. How can I correct this ant directive so that StringUtil.class is inside the com/test directory in the jar?

<jar destfile="myjar.jar" >
  <fileset file="${build}/com/test/StringUtil.class"/>
</jar>

Thanks!

+4  A: 

You need to tell ant to include the base directory, then tell it to include only the desired file. Like so:

<jar destfile="myjar.jar" >
  <fileset dir="${build}" includes="com/test/StringUtil.class"/>
</jar>

Here's the doc for <fileset> tags.

sblundy
Perfect! Thanks very much!
Markus