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?