This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I set environment variables in Ant

 
Dar Var
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to be able to set Environment variables from within my Ant script depending on the OS.

I want to run the following from within Ant:


If the Ant script is run on Windows:

set MY_VARIABLE_NAME=C:/lOCATION

set PATH=C:\Location;%PATH%


If the Ant script is run on Unix:

MY_VARIABLE_NAME=/location
export VBROKER_ADM

PATH=/location:${PATH}
export PATH
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Detecting the platform is easy - all of the JRE environment variables defined in java.System properties are available to Ant. I've run scripts that knew whether they were running Windows or Unix and, if Unix, whether Linux or Solaris.

Exporting out of Ant is a little more challenging.
 
Radu Codrin Leterna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Exporting out of Ant is a little more challenging.


I know this topic was opened a long time ago... but can you detail the exporting of variables for Solaris out of Ant? Thanks!
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Radu and welcome to Javaranch!

Can I suggest you start a new thread with your exact issue? Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic