Compiling Java code using Ant within Eclipse

J

junk

Hi,

I am using Eclipse 3.0 to create a number of Java projects all located
within the same workspace. I had everything building ok but decided to
migrate to using Ant to try and manage things a bit better.

Now when I try and compile my app using Ant it does not find references
to external libraries. Now I suspect I need to specify the classpath in
the build.xml file, but is there a way of telling it to use the set of
libraries I have allready specified via Project->Properties->Java Build
Path->Libraries?

I currently have a build.xml file for each of the projects in my
workspace. Is there a way of creating a build.xml file which invokes
each of these in turn so that I can just do one big build?
Thanks for your help.
Andy
 
T

Thomas Åhlén

I currently have a build.xml file for each of the projects in my
workspace. Is there a way of creating a build.xml file which invokes
each of these in turn so that I can just do one big build?
Thanks for your help.
Andy

I do it this way:

Create the file: build.properties
#
# Required external packages
#
# Log package
log4j.jar=lib/log4j-1.2.8.jar
# XML package
xerces.jar=lib/xerces-1.3.0.jar

your build.xml should then look something like this

<!-- ================================================================== -->
<!-- Create classpath -->
<!-- ================================================================== -->
<path id="classpath">
<pathelement location="${log4j.jar}"/>
<pathelement location="${xerces.jar}"/>
</path>

<!-- =================================================================== -->
<!-- Compiles the source directory -->
<!-- =================================================================== -->
<target name="compile" depends="prepare">
<javac
srcdir="${build.src}"
destdir="${build.dest}"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}">
<classpath refid="classpath"/>
</javac>
</target>
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top