ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Atul V. Setlur" <>
Subject Re: Access environment variables within ANT?
Date Tue, 13 Feb 2001 15:37:01 GMT
> Is it possible to access environment variables within ANT? e.g. If I create
> an environment variable MICK, is there any way of access in within ant, ie
> ${env.MICK}

You need to specify it as a Java property i.e.,  -D<propertyName>=<value>
specified on the command line when Ant is launched. Please refer to the
documentation under "Running Ant" for more information. I am including the
relevant piece below.

You can also set properties which override properties specified in the
buildfile (see the property task). This can be done with the
-D<property>=<value> option, where <property> is the name of the property
<value> the value. This can also be used (and is the only way since Java can
not access them) to have access to your environment variables, just pass
-DMYVAR=%MYVAR% (Windows) or -DMYVAR=$MYVAR (Unix) to Ant, you can then access
these variables inside your build-file as ${MYVAR}.


View raw message