Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I reference a classpathref in a war task?

Tags:

ant

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?

like image 478
Thierry-Dimitri Roy Avatar asked Feb 26 '09 15:02

Thierry-Dimitri Roy


1 Answers

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"/>
like image 130
Olivier Avatar answered Nov 15 '22 07:11

Olivier