On Thu, 6 Dec 2001, Hannes van der Merwe <[EMAIL PROTECTED]> wrote: > Maybe it is a stupid question, but how should I do that?
Probably more a sign of a flawed documentation (patches are always welcome). First, define the classpath that you want to use and don't care for the environment variable. Do this at the top level. <path id="my-classpath-without-environment"> ... whatever you want to put in here ... </path> Next, pull in all environment variables as Ant properties <property environment="env" /> Then, make all targets that will use you custom classpath in one of their tasks depend on the following target: <target name="set-path" depends="set-path-with-env,set-path-without-env" /> If CLASSPATH has been set, we now have a property env.CLASSPATH, use it (I assume you want to prepend it): <target name="set-path-with-env" if="env.CLASSPATH"> <path id="use-this-path"> <pathelement path="${env.CLASSPATH}" /> <pathelement refid="my-classpath-without-environment" /> </path> </target> If it has not been set, just use the path already defined, just give it a different name: <target name="set-path-with-env" unless="env.CLASSPATH"> <path id="use-this-path"> <pathelement refid="my-classpath-without-environment" /> </path> </target> And use the path named "use-this-path" in all the tasks that need it. There is a different solution that relies on property immutability and is a lot more compact (but maybe more difficult to understand). Put this outside of any target (or inside a target all your other targets depend upon): <property environment="env" /> <property name="env.CLASSPATH" value="" /> <path id="use-this-path"> <pathelement path="${env.CLASSPATH}" /> ... whatever you want to put in here ... </path> Stefan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>