Search code examples
javaantjarclasspathbuild.xml

Adding folders with libs in ant buildfile


in my Project i have the /lib and /WEB-INF folder. I would need to add both folders (or the .jar files from those folders with sub folders) to the classpath.

I tried something like this, but it didnt work:

<property name="lib.dir"        value="lib"/>
<property name="webinf.dir"     value="WEB-INF"/>

<path id="classpath">
    <fileset dir="${lib.dir}">
        <include name="${lib.dir}/**/*.jar ${webinf.dir}/**/*.jar"/>
    </fileset>
</path>

Solution

  • You can try this:

    <property name="web-inf.dir" value="WEB-INF" />
    <property name="lib.dir" value="lib" />
    
    <path id="classpath">
        <fileset dir="${web-inf.dir}" includes="**/*.jar" />
        <fileset dir="${lib.dir}" includes="**/*.jar" />
    </path>
    

    But shouldn't the web-lib dir be something like webContent\WEB-INF\lib? If yes, then web-inf.dir should be:

    <property name="web-inf.dir" value="webContent/WEB-INF/lib" />