source: release-kits/wirk3/ant-scripts/tasks/antelope/docs/manual/bk03ch20.html@ 15023

Last change on this file since 15023 was 15023, checked in by oranfry, 16 years ago

did the bulk of the work on wirk3

File size: 5.2 KB
Line 
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 20. AntCallBack</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="Antelope Users Guide"><link rel="up" href="bk03.html" title="Additional Ant Tasks"><link rel="prev" href="bk03ch19.html" title="Chapter 19. AntFetch"><link rel="next" href="bk03ch21.html" title="Chapter 21. Call Task"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 20. AntCallBack</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk03ch19.html">Prev</a> </td><th width="60%" align="center">Additional Ant Tasks</th><td width="20%" align="right"> <a accesskey="n" href="bk03ch21.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="antcallback"></a>Chapter 20. AntCallBack</h2></div></div></div>
2<STYLE TYPE="text/css"> <!-- @import url(./style.css); --> </STYLE>
3 <p>
4AntCallBack is identical to the standard 'antcall' task, except that it allows properties set in the called target to be available in the calling target.
5</p><p>
6To use this task in your build files, include a task definition like this:
7</p><pre class="programlisting">
8
9 &lt;taskdef name="antcallback" classname="ise.antelope.tasks.AntCallBack"/&gt;
10
11</pre><p>
12</p><p>
13Some background may be in order: When the &lt;antcall&gt; task is used, in actuality, a new Ant project is created, and depending on the inheritAll property, it is populated with properties from the original project. Then the requested target in this new project is executed. Any properties set in the new project remain with that project, they do not get "passed back" to the original project. So, for example, if the target in the new project sets a property named "image.directory", there is no reference to that property in the original. Here's an example of what I mean:
14</p><p>
15</p><pre class="programlisting">
16
17 &lt;target name="testCallback" description="Test CallBack"&gt;
18 &lt;taskdef name="antcallback" classname="ise.antelope.tasks.AntCallBack" classpath="${antelope.home}/build" /&gt;
19 &lt;antcallback target="-testcb" return="a, b"/&gt;
20 &lt;echo&gt;a = ${a}&lt;/echo&gt;
21 &lt;echo&gt;b = ${b}&lt;/echo&gt;
22 &lt;/target&gt;
23
24 &lt;target name="-testcb"&gt;
25 &lt;property name="a" value="A"/&gt;
26 &lt;property name="b" value="B"/&gt;
27 &lt;/target&gt;
28
29</pre><p>
30The output from executing "testCallback" looks like this:
31</p><pre class="programlisting">
32a = A
33b = B
34</pre><p>
35Contrast with this output from "antcall":
36</p><pre class="programlisting">
37a = ${a}
38b = ${b}
39</pre><p>
40</p><p>
41This is an often requested feature for Ant, at least judging from the Ant mailing lists. I assume this is because it allows a more functional programming style than Ant natively supports. The proper Ant way of doing the above is like this:
42</p><pre class="programlisting">
43
44 &lt;target name="testCallback" description="Test CallBack" depends="-testcb"&gt;
45 &lt;echo&gt;a = ${a}&lt;/echo&gt;
46 &lt;echo&gt;b = ${b}&lt;/echo&gt;
47 &lt;/target&gt;
48
49 &lt;target name="-testcb"&gt;
50 &lt;property name="a" value="A"/&gt;
51 &lt;property name="b" value="B"/&gt;
52 &lt;/target&gt;
53
54</pre><p>
55This is actually looks cleaner in this situation, and is faster, too. There is significant overhead in using both "antcall" and "antcallback" in that they both require a lot of object instantiation and property copying. That said, many people prefer to use "antcall" and "antcallback" as it better fits their logic and style.
56</p><p>
57The attributes for AntCallBack are identical to the 'antcall' task, with one additional, optional attibute. This attribute is named "return" and can be either a single property name or a comma separated list of property names.
58</p><div class="table"><a name="id2524711"></a><p class="title"><b>Table 20.1. AntCallBack Attributes</b></p><table summary="AntCallBack Attributes" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td>return</td><td>A comma separated list of property names. Whitespace is allowed, so either "a,b" or "a, b" are acceptable.</td><td>None</td><td>No</td></tr></tbody></table></div><p>
59</p><p>
60For other attribute and nested element information and more examples, see the documentation for the "antcall" task in the Ant documentation.
61</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk03ch19.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk03ch21.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 19. AntFetch </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 21. Call Task</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.