I have been given an application which uses a build.xml file for building purposes. I have very little knowledge of Apache Ant and the classpaths seems to be the following:
<!-- Classpath -->
<path id="development-classpath">
<fileset dir="${libs.dir}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="."/>
<pathelement location="${classes.dir}"/>
<pathelement location="${configuration.dir}/langs/"/>
<pathelement location="${fits.dir}/xml/nlnz"/>
</path>
As I want to use Eclipse own building facilities I would like to assign these classpaths variable in Eclipse, which I don’t have much experience with. How do I do it?
Here’s the manual way to configure Eclipse to mimic what ant will do using the build.xml file. This should get you started:
Open Eclipse, open the
"Java"Perspective. Right click the project and choose"Build Path / Configure Build Path". Alternatively click"Project"Menu, and choose"properties", then click"Java Build Path". Click the Libraries Tab. This is where you tell Eclipse where the jars needed build your project are located.From the build.xml snippet, the first
"<fileset>"specifies that all the jars you need are under the<project>/libsdirectory (I’m guessing that${libs.dir}corresponds to"libs"but you might want to double check. It should be defined near the top of build.xml). So click,"Add Jars...", navigate into<project>/libs, highlight all the jars inside the directory and then click"Ok".The first and second
<pathelement>tags are telling ant to use the current directory and the classes directory. Eclipse should already take care of this by default, but to double check, click on the"Source"Tab (should be in the same"Java Build Path"dialog as the “Libraries” tab). Thedefault output foldershows where eclipse will compile java code to .class files. TheSource folders on build pathshows where all your source code is that Eclipse should try to compile.Finally, The last two
<pathelement>tags tell ant to use some resource/config files under${configuration.dir}/langsand${fits.dir}/xml/nlnz. You can add these similar to the way you added the jars. Click"Libraries"Tab. Then choose"Add Class Folder"and highlight both the"langs"and"nlnz"folders.Hope this give you some insight into where Eclipse looks for jar dependencies, class files and resources.
Having said all this, as you become more familiar with Eclipse and build tools, you’ll probably discover that this probably isn’t the best way to go because it’s very easy for the build.xml and eclipse configuration to get out of sync. There are ways to tell eclipse to build using an ant build.xml file (check out
File->New Project->Java Project form Existing Ant Buildfile). And there are also ways to run ant targets from within Eclipse (check outWindow -> show view -> ant).