I want to change "variable" in Ant file, in one target and see that change in another target.
<variable name="foo" value="hello" />
<target name="print-me">
<echo message="${foo}" />
<antcall target="change-me" />
<echo message="${foo}" />
</target>
<target name="change-me">
<variable name="foo" value="world" />
</target>
While I want it to print: 'hello , world' , it prints 'hello, hello'
Either use :
<target name="change-me">
<variable name="foo" unset="true"/>
<variable name="foo" value="world"/>
</target>
as Oers already mentioned in his comment to your question or use a more
straightforward approach with the let task
of Ant addon Flaka :
<project xmlns:fl="antlib:it.haefelinger.flaka">
...
<!-- overwrite any existing property or userproperty
(those properties defined on the commandline via -Dfoo=bar ..) -->
<fl:let> foo ::= 'world'</fl:let>
...
</project>