Content

ramblings of a coldfusion developer

Using Environment Properties In Ant

Friday 24 April 2009 - Filed under Code

Tinking around with Ant I found out you can reference system environment properties within your build file.

So in Windows for example you can run SET at the command line and get a long list of properties:


U:\>set
ALLUSERSPROFILE=C:\Documents and Settings\All Users
ANT_HOME=D:\ant
APPDATA=C:\Documents and Settings\priestj\Application Data
CLIENTNAME=zappa

You can easily reference these in your build file – first set property environment to “env”:


Now we’ll add some of our Windows system properties (note these are case sensitive!):


Running this we can see these properties are picked up by Ant!


Buildfile: D:\build.xml
echo:
[echo] env.ALLUSERSPROFILE:   C:\Documents and Settings\All Users
[echo] env.ANT_HOME:   C:\eclipse\plugins\org.apache.ant_1.7.0.v200803061910
[echo] env.APPDATA:   C:\Documents and Settings\priestj\Application Data
[echo] env.CLIENTNAME:   zappa
Tagged:

2009-04-24  »  Jim Priest

Talkback x 3

  1. Steve 'Cutter' Blades
    24 April 2009 @ 12:58 pm

    Sweet! Hadn’t thought of attaching to the environment variables, that could be very handy.

  2. marc esher
    24 April 2009 @ 1:57 pm

    Excellent. Very useful, Jim

  3. kumar kauhsal
    17 February 2010 @ 8:56 am

    Superb… Its really very useful…Never thought of these features..
    Thanks

Share your thoughts

Re: Using Environment Properties In Ant







Tags you can use (optional):
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>