How to change the Path variable in ant exec task?

TechSpellBound picture TechSpellBound · Jan 30, 2013 · Viewed 9.7k times · Source

I tried setting the Path variable in ant exec task using this link. But its not working somehow. I am trying to add THRIFT_HOME which is set to basedir currently and I have the thrift.exe file in the basedir.

Also, when I change executable attribute value to thrift.exe, the thrift compiler works properly but the basedir is not added to the Path.

<exec executable="thrift">
    <env key="Path" value="${env.Path};${THRIFT_HOME}" />
</exec>

I also tried using the setx command as:

<exec executable="setx">
    <arg value="Path"/>
    <arg value="%Path%;${THRIFT_HOME}"/>
</exec>

but it still does not work.

Any help would be appreciated!

Answer

Peter Butkovic picture Peter Butkovic · Jan 30, 2013

how about this:

<property environment="env"/>
<!-- to see if you can access it -->
<echo message="${env.Path}" />
<exec executable="thrift">
    <env key="Path" value="${env.Path};${THRIFT_HOME}" />
</exec>

I've found a hint here: http://www.factsandpeople.com/facts-mainmenu-5/23-other-software-technologies/125-using-environment-variables-in-ant-environment-variables-are-not-evaluated