Reputation: 903
My problem is;
When I call an antcallback function more than one, It returns the same value always. Check out the following code :
<project name="AntCallBack" default="testFnc" basedir=".">
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<target name="acbFnc" description="Sub Function" >
<echo message="[acbFnc] started"/>
<property name="out.file" value="${in.file}"/>
<echo message="[acbFnc] ended."/>
</target>
<target name="testFnc" description="Main" >
<antcallback target="acbFnc" return="out.file" >
<param name="in.file" value="TEST-1" />
</antcallback>
<echo message="CALL - 1 : out.file : ${out.file}" />
<antcallback target="acbFnc" return="out.file" >
<param name="in.file" value="TEST-2" />
</antcallback>
<echo message="CALL - 2 : out.file : ${out.file}" />
</target>
</project>
The result is :
$ /home/apache-ant-1.9.4/bin/ant -f AntCallBackTest.xml
Buildfile: AntCallBackTest.xml
testFnc:
acbFnc:
[echo] [acbFnc] started
[echo] [acbFnc] ended.
[echo] CALL - 1 : out.file : TEST-1
acbFnc:
[echo] [acbFnc] started
[echo] [acbFnc] ended.
[echo] CALL - 2 : out.file : TEST-1
BUILD SUCCESSFUL
Total time: 0 seconds
As you see I sent "param name="in.file" value="TEST-1" " in first call,
And I sent "param name="in.file" value="TEST-2" " in second call,
But It always returned the first value :
[echo] CALL - 1 : out.file : TEST-1
[echo] CALL - 2 : out.file : TEST-1
What am I doing wrong?
Thanks in advance
Upvotes: 2
Views: 1185
Reputation: 903
I found the solution :
I have to unset the variable before second call with :
<var name="out.file" unset="true"/>
I mean, it should be like this :
<target name="testFnc" description="Main" >
<antcallback target="acbFnc" return="out.file" >
<param name="in.file" value="TEST-1" />
</antcallback>
<echo message="CALL - 1 : out.file : ${out.file}" />
<var name="out.file" unset="true"/>
<antcallback target="acbFnc" return="out.file" >
<param name="in.file" value="TEST-2" />
</antcallback>
<echo message="CALL - 2 : out.file : ${out.file}" />
</target>
Upvotes: 3