ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy Lambert <anto...@gmx.de>
Subject Re: AW: AW: Ant Environment
Date Thu, 18 Mar 2010 15:44:36 GMT
Hello Philip,

Ant does not have the power to change the environment variables which 
were assigned by the starting shell. Perl can do that I think.

Environment variables do not matter much to ant itself, my guess is that 
you want to run several commands from ant which require special env 
variables.

The exec task has an env nested element to set environment variables.

<exec executable="cmd">

    <arg value="some.bat"/>
    <env key="LALA_HOME" value="C:\Program Files\LALA"/>
</exec>

If you want to pass some environment variables to several <exec/> 
invocations, you can use presetdef to create a variation of exec which 
will always set some environment variables. Or you can write a wrapper 
.BAT or .CMD file which sets whatever you want, and always execute your 
commands through the wrapper.


Regards,

Antoine

Maurer Philipp wrote:
> Thanks,
>
> Sure, I could use setx, but this changes the environment variable on my maschine i.e.
in every new shell I open, but not the current one. I guess that is not even possible using
a normal e.g. C++ program.
>
> Philipp
>
> -----Ursprüngliche Nachricht-----
> Von: Antoine Levy Lambert [mailto:antoine@gmx.de] 
> Gesendet: Donnerstag, 18. März 2010 14:09
> An: Ant Users List
> Betreff: Re: AW: Ant Environment
>
> Agreed with Jan. If you want to modify permanently the environment 
> variables of Windows machines, one of the tools you
> can use is VBS. I think you will find articles about which API calls to 
> use to do this in VBS.
> Ant can kick off a VBS script if you do
> <exec executable="wscript.exe">
>          <arg value="full path to vbs file"/>
> </exec>
>
> Regards,
>
> Antoine
>
>
> Jan.Materne@rzf.fin-nrw.de wrote:
>   
>> You are right: you cannot change the values from Ant.
>> You could use the "setx" system command, so NEW processes will get the new values.
>> I dont know any possibility to change the environment for RUNNING processes.
>> Maybe via PowerShell, WindowsManagementInstrumentation, ... a la
>>    for(Projess p : allRunningProcesses) 
>>      p.setEnv(key, newValue) 
>>
>>
>> Jan
>>
>>   
>>     
>>> -----Ursprüngliche Nachricht-----
>>> Von: Maurer Philipp [mailto:philipp.maurer@rheinmetall-ad.com] 
>>> Gesendet: Donnerstag, 18. März 2010 08:18
>>> An: user@ant.apache.org
>>> Betreff: Ant Environment
>>>
>>> Hello,
>>>
>>>  
>>>
>>> I'd like to make ant modify my current shell environment on Windows
>>> maschines. 
>>>
>>>
>>> Example:
>>>
>>> I'd like something like an 'ant set' (target 'set') that sets some
>>> 'foo=bar'. Calling that target should have the same effect 
>>> than calling
>>> 'set foo=bar'. 
>>>
>>>  
>>>
>>> I tried some stuff: calling python scripts, generating and executing
>>> batch files, using setx, using cmd /C set. 
>>>
>>>  
>>>
>>> I think this is a more general problem and I think it is not 
>>> possible at
>>> all (maybe someone could confirm this):  
>>>
>>> All processes are forked or run in a separate shell and so in 
>>> a separate
>>> environment. Changing this environment does not affect the environment
>>> from which I'm calling ant.
>>>
>>>  
>>>
>>> Any ideas ? Windows-System calls ? Python calls ? 
>>>
>>>  
>>>
>>> Thanks,
>>>
>>> Philipp
>>>
>>>  
>>>
>>>  
>>>
>>>
>>>     
>>>       


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message