setting classpaths with Ant

E

El Durango

I am writing an ant script which should set the classpaths for the necessary
Jar files.
Here is what I have:

<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="compile" basedir=".">
<property name="src" value="."/>
<property name="build" value="build"/>
<property name="lib" value="lib"/>
<target name="init">
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init">
<!-- Compile the java code -->

<javac srcdir="${src}" destdir="${build}"/>
<classpath>
<pathelement location="${baselib}\xercesImpl.jar" />
<pathelement location="${lib}\xmlParserAPIs.jar" />
<pathelement location="${lib}\xml-apis.jar" />
<pathelement location="${lib}\servlet-api.jar" />
<pathelement
location="${lib}\commons-fileupload-1.0.jar" />
</classpath>
</target>
</project>

However this is not working, as it fails with unresolved symbol errors.

Can anyone let me know how I can set classpaths using Ant, I seem to be
doing it the wrong way.

thanks.
 
W

WJ

I generally use fileset for my classpath. Like this:

<classpath>
<fileset dir="${lib}">
<include name="${baselib}/xercesImpl.jar"/>
<include name="${lib}/xmlParserAPIs.jar"/>
<include name="${lib}/xml-apis.jar"/>
<include name="${lib}/servlet-api.jar"/>
</fileset>
</classpath>

Also note, I generally use forward slashes instead of back slashes, even on
Windows. I've
had problems with back slashes from time to time.

You may also want to echo what ant thinks your ${lib} dir is. e.g.
<echo message="${lib}" />

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top