ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ninju Bohra <ninju_bo...@yahoo.com>
Subject Re: Antcall task not doing what I want it to do!
Date Fri, 17 Mar 2006 03:46:54 GMT
Hello Res Pons,
 
By design the <antcall> task loads an new "ANT" session in which the "target" task is
run in and when the "target" task is completed the "ANT" session is destroyed and no property
values/path refs are carried back into the calling session (think of the <antcall> task
as a subroutine call where all the state (i.e. property creation/assingments) is kept in local
variables, when the rountine finishes all the local variables are gone).
 
Prior to some earlier verison (ANT 1.6 I believe) the only way to "chain" targets together
and allow property values to remain was through the depends="<list of targets>" attribute
because each of the dependent targets would run in same "ANT" session.
 
After the ANT 1.6, the <macrodef> task was created which allowed you to define a resuable
set of ANT tasks that ran under the same "ANT" session.  If within a <macrodef> task
you set a property (or path set) it would be visible (and final) for the life of the 'ANT'
session.
 
You can re-write you example, using <macrodef>s as follows:
 
<macrodef name="newbuildnum" > 
  <sequential>
  <buildnumber file="build/build.number"/>
  <property name="full.build.number"  value="${build.number}" />
  <echo message="And the full build.number in destination target is ==> 
${full.build.number}" />
  </sequential>
</macrodef>

<target="callbuildnumber" >
<!-- we now invoke the macrodef we created.  Note we reference the macrodef as an element
   just a "custom" task --->
  </newbuildnum>
  <echo message="And the full build.number in calling target is ==> 
${full.build.number}" />
</target>

 Please read up on the <macrodef> task in the ANT help for further information on this
powerful new addition.
 
Also for the ANT documentation group,  I might be nice to add some verbage to the <antcall>
task documentation pointing that fact that properties values are transported across the <antcall>.
 
After all that has been said, if you REALLY REALLY need to bring back some property values
from a <antcall> invocation you can look into the <antcallback> task from the
ant-contrib project, however I would use that only as a last resort.



----- Original Message ----
From: Res Pons <pons32@hotmail.com>
To: user@ant.apache.org
Sent: Thursday, March 16, 2006 6:52:54 PM
Subject: Antcall task not doing what I want it to do!


Hi everyone!

I'm making an antcall from the source target to its destination target.

<targe="callbuildnumber" >
  <antcall target="newbuildnum" />
  <echo message="And the full build.number in calling target is ==> 
${full.build.number}" />
</targe>

<targe="newbuildnum" >
  <buildnumber file="build/build.number"/>
  <property name="full.build.number"  value="${build.number}" />
  <echo message="And the full build.number in destination target is ==> 
${full.build.number}" />
</targe>

Naturally the echo stmt in the newbuildnum target works but how do I get it 
back to callbuildnumber target, the echo stmt in this target does not work?

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message