Hello,
I'm tyring to use Ant to create a jar file with selected directories in
a potentially large tree.
For example:
<property name="top.dir" value="/javasrc"/>
<property name="util.dir" value="/javasrc/my/stuff/util"/>
<property name="Proj1.dir" value="/javasrc/other/stuff/Proj1"/>
<property name="jar.file" value="Proj1.jar"/>
I can do this:
<jar basedir="${top.dir}" destfile="${top.dir}/${jar.file}"
includes="**/*.class">
But of course I get all classfiles under /javasrc. I've been tinkering
with includes= and <fileset> to try and pick and choose the directories
to include, without success. Also, I often get just the class file name
referenced in the manifest, but what I need is
/javasrc/my/stuff/util/a.class
So far the only thing that's worked is includesfile, but then I have to
maintain the file. This seems like a pretty natural thing to do... Any
suggestions???
Thanks,
Dave
DaveO. - 30 Mar 2006 20:00 GMT
Well, I solved it... The key was in this sentence in the Ant docs for
the jar task:
The extended fileset and groupfileset child elements from the zip task
are also available in the jar task.
Which enabled me to do this:
<property name="top.dir" value="/javasrc"/>
<property name="util.dir" value="my/stuff/util"/>
<property name="Proj1.dir" value="other/stuff/Proj1"/>
<property name="jar.file" value="Proj1.jar"/>
<target name="jar">
<jar destfile="${top.dir}/${jar.file}">
<zipfileset dir="${top.dir}/${jws.dir}" prefix="${util.dir}"
includes="*.class"/>
<zipfileset dir="${top.dir}/${jcw.dir}" prefix="${Proj1.dir}"
includes="*.class"/>
</jar>
</target>
The jar task specifies no contents, and each of the zipfileset elements
specifies a directory, and prepends the path when the files are stored.
cheers,
Dave
Roedy Green - 30 Mar 2006 20:51 GMT
> <jar destfile="${top.dir}/${jar.file}">
> <zipfileset dir="${top.dir}/${jws.dir}" prefix="${util.dir}"
>includes="*.class"/>
> <zipfileset dir="${top.dir}/${jcw.dir}" prefix="${Proj1.dir}"
>includes="*.class"/>
> </jar>
check out genjar. It makes sure you have not forgotten anything or
including stuff that does not need to be there.
See http://mindprod.com/jgloss/genjar.html
http://mindprod.com/jgloss/ant.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.