Ant (the software tool- not the insect) question

Quickie for ANT users I hope:

How can I add an external ‘lib’ directory, identified by an environment variable, to a classpath in ant?

For example, suppose I have some jar files located in “C:\SomeThirdPartyStuff\lib” and have the environment variable THIRDPARTY_HOME set to “C:\SomeThirdPartyStuff”

My project is located in “C:\MyProj” and I have build.xml in the root of that project which begins


<?xml version="1.0"?>
<project name="My Project" basedir=".">


I tried to set up a path thus:



	<!-- get access to environment variable  -->
	<property environment="env" />

	<property name="class.root" value="classes" />

	<path id="project.class.path">
		<pathelement location="${class.root}" />

		<!-- Include jars in third party lib -->
		<fileset dir="${env.THIRDPARTY_HOME}\lib">
			<include name="*.jar" />
		</fileset>
	</path>


What happens is that the THIRDPARTY_HOME environment variable gets added to the basedir, giving “C:\MyProj\C:\SomeThirdPartyStuff\lib” which is obviously not what is wanted. How can I get the correct path?

I have no idea what ant is but it sounds like you need some sort of “mappath” command that will dynamically find the location of the folder.

Maybe that term (mappath) will help you in your search for an answer?