tags:

views:

177

answers:

1

I declare the following classpath reference for my application librairies:

<path id="libraries">
    <fileset dir="${lib.dir}" includes="**/*.jar" />
</path >

I can compile the code using the classpath of the librairies:

<javac srcdir="${src}" destdir="${build.classes}" classpathref="libraries"/>

But I cannot find a way to include the fileset of librairies also in my WAR file:

<war destfile="${release.dir}/rel.war" webxml="${webinf}">
    <classes dir="${build.classes}"/>

     <!-- I need to copy paste the same directory declaration! -->
    <lib dir="${lib.dir}" includes="**/*.jar"/> 
</war>

How can I replace the "lib" declaration with something that reuse the same path as in my javac task?

+1  A: 

Declare the fileset out of the path and assign it an identifier:

<fileset id="xxx" dir="..." includes="..." />

Then reference the identifier in both declarations (lib specifies a fileset, so you don't have to use nesting):

<path id="libraries">
    <fileset refid="xxx"/>
</path>
...
<lib refid="xxx"/>
Olivier