Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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
Pie
Posts: 18012
47
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