How to set the path environment variable from ant script
相关问题
- $ENV{$variable} in perl
- Using getenv function in Linux
- Meaning of headless and -D option in JAVA_OPTS
- putenv warning with C++
- How can I have my ant task pass or fail based on t
相关文章
- How should I configure log4net to write to %LOCALA
- Override env values defined in container spec
- Unable to see or modify value of PYTHONHASHSEED th
- Android set(get) environmental variables in Java
- Passing command line arguments to Java via ant bui
- ANT - Could not load a dependent class com/jcraft/
- Expand environment variables in Qt (getenv equival
- Detect if python script is run from console or by
since I don't have enough reputation to comment on the
<variable ...
suggestions my comment as an answer ... :-/In ("newer") ant-contrib (extra ANT package) the task is not called
<variable ...
but<var ...
!(but it didn't work for me anyways since I think the manipulation of the
env.*
(created by<property environment="env" ... />
task) Java properties/variables is only relevant for tasks/processes evaluating these Java properties which are not automatically "synced back" to the OS environment variables)You can use setx command to set the environment variables.
For setx command help refer http://ss64.com/nt/setx.html
Is this for an
<exec>
task?You can set environment variables when you run an
<exec>
task:You can use
<property environment="env"/>
to expand the path:If this is for some custom task that requires an environment variable, but doesn't allow you to set the environment variable in the task if one isn't set, you can try setting it in:
This might set an environment variable called
foo
to the value ofbar!bar!
. I remember something about this, but wasn't able to get it to work.The other thing you can do is have one ant script execute another and have the first ant script set the environment value. I did this when I had to set
ANT_OPT
.I found it works by quote the value of variable
To set the environment variables through Ant, try calling exec task and set the command line values. I have not tried this by the way, but it should work.
You can use to expand the path:
And then you can execute for instance
sh
fromant
toexport
the environment variable:Or execute your command and set
env
withvalue
, like so: