|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <html>
-
- <head>
- <meta http-equiv="Content-Language" content="en-us"></meta>
- <title>MacroDef Task</title>
- </head>
-
- <body>
-
- <h2><a name="macrodef">MacroDef</a></h2>
- <h3>Description</h3>
- <p>
- This defines a new task using a <sequential> or <parallel>
- nested task as a template. Nested elements <attribute> and
- <element> are used to specify attributes and elements of
- the new task. These get substituted into the <sequential>
- or <parallel> task when the new task is run.
- </p>
- <p>
- Introduced in ant1.6 <font color="red">Experimental</font>.
- </p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">The name of the new definition</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">uri</td>
- <td valign="top">
- The uri that this definition should live in.
- </td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">attributestyle</td>
- <td valign="top">
- <em>Temporary</em>
- this attribute specifies if the attribute is in ant style
- (i.e. ${attributeName}) or xpath style (i.e @attributeName).
- Valid values are "ant" and "xpath". The default value
- is "ant".
- </td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h3>Parameters specified as nested elements</h3>
- <h4>attribute</h4>
- <p>
- This is used to specify attributes of the new task. The values
- of the attributes get substituted into the templated task.
- The attributes will be required attributes unless a default
- value has been set.
- </p>
- <p>
- This attribute is placed in the body of the templated
- task using the ant property notation - ${attribute name}.
- Note that is not an actual ant property.
- </p>
- <p>
- If the attribute style is set to "xpath", the attribute is
- specified in the body of the template task by prefixing the
- name with a "@".
- </p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">The name of the new attribute</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">default</td>
- <td valign="top">
- The default value of the attribute.
- </td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h4>element</h4>
- <p>
- This is used to specify nested elements of the new task.
- The contents of the nested elements of the task instance
- are placed in the templated task at the tag name.
- </p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">The name of the new attribute</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">optional</td>
- <td valign="top">
- If true this nested element is optional. Default is
- false - i.e the nested element is required in
- the new task.
- </td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
-
- <h3>Examples</h3>
- <p>
- The following example defined a task called testing and
- runs it.
- </p>
- <blockquote>
- <pre>
- <macrodef name="testing">
- <attribute name="v" default="NOT SET"/>
- <element name="some-tasks" optional="yes"/>
- <sequential>
- <echo>v is ${v}</echo>
- <some-tasks/>
- </sequential>
- </macrodef>
-
- <testing v="This is v">
- <some-tasks>
- <echo>this is a test</echo>
- </some-tasks>
- </testing>
- </pre>
- </blockquote>
- <p>
- The following fragment sets the attribute style to "xpath"
- for the macro definition <testing> and calls the
- macro. The fragment should output "attribute is this is a test".
- </p>
- <blockquote>
- <pre>
- <macrodef name="testing" attributestyle="xpath">
- <attribute name="abc"/>
- <sequential>
- <echo>attribute is @abc</echo>
- </sequential>
- </macrodef>
-
- <testing abc="this is a test"/>
- </pre>
- </blockquote>
- <p>
- The following fragment defines a task called <call-cc> which
- take the attributes "target", "link" and "target.dir" and the
- nested element "cc-elements". The body of the task
- uses the <cc> task from the
- <a href="http://ant-contrib.sourceforge.net/">ant-contrib</a> project.
- </p>
- <blockquote>
- <pre>
- <macrodef name="call-cc">
- <attribute name="target"/>
- <attribute name="link"/>
- <attribute name="target.dir"/>
- <element name="cc-elements"/>
- <sequential>
- <mkdir dir="${obj.dir}/${target}"/>
- <mkdir dir="${target.dir}"/>
- <cc link="${link}" objdir="${obj.dir}/${target}"
- outfile="${target.dir}/${target}">
- <compiler refid="compiler.options"/>
- <cc-elements/>
- </cc>
- </sequential>
- </macrodef>
- </pre>
- </blockquote>
- <p>
- This then can be used as follows:
- </p>
- <blockquote>
- <pre>
- <call-cc target="unittests" link="executable"
- target.dir="${build.bin.dir}">
- <cc-elements>
- <includepath location="${gen.dir}"/>
- <includepath location="test"/>
- <fileset dir="test/unittest" includes = "**/*.cpp"/>
- <fileset dir="${gen.dir}" includes = "*.cpp"/>
- <linker refid="linker-libs"/>
- </cc-elements>
- </call-cc>
- </pre>
- </blockquote>
- <hr>
- <p align="center">Copyright © 2003 Apache Software
- Foundation. All rights Reserved.</p>
-
- </body>
- </html>
-
|