Author: jhm Date: Wed May 31 10:00:15 2006 New Revision: 410598 URL: http://svn.apache.org/viewvc?rev=410598&view=rev Log: Example how to load an Antlib from inside a buildfile.
Modified: ant/core/trunk/docs/manual/CoreTasks/typedef.html ant/core/trunk/docs/manual/CoreTypes/antlib.html Modified: ant/core/trunk/docs/manual/CoreTasks/typedef.html URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/typedef.html?rev=410598&r1=410597&r2=410598&view=diff ============================================================================== --- ant/core/trunk/docs/manual/CoreTasks/typedef.html (original) +++ ant/core/trunk/docs/manual/CoreTasks/typedef.html Wed May 31 10:00:15 2006 @@ -169,6 +169,8 @@ <typedef name="urlset" classname="com.mydomain.URLSet"/> </pre> The data type is now available to Ant. The class <code>com.mydomain.URLSet</code> implements this type.</p> + + <p> Assuming a class <i>org.acme.ant.RunnableAdapter</i> that extends Task and implements <i>org.apache.tools.ant.TypeAdapter</i>, @@ -181,6 +183,8 @@ classname="com.acme.ant.RunClock" adapter="org.acme.ant.RunnableAdapter"/> </pre> + + <p> The following fragment shows the use of the classpathref and loaderref to load up two definitions. @@ -200,8 +204,22 @@ loaderref="lib.path.loader" /> </pre> + + + <p> + If you want to load an antlib into a special xml-namespace, the <tt>uri</tt> attribute + is important: + </p> + <pre> + <project xmlns:antcontrib="antlib:net.sf.antcontrib"> + <taskdef uri="antlib:net.sf.antcontrib" + resource="net/sf/antcontrib/antlib.xml" + classpath="path/to/ant-contrib.jar"/> + </pre> + + <hr> -<p align="center">Copyright © 2001-2005 Apache Software +<p align="center">Copyright © 2001-2006 Apache Software Foundation. All rights Reserved.</p> </body> Modified: ant/core/trunk/docs/manual/CoreTypes/antlib.html URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/antlib.html?rev=410598&r1=410597&r2=410598&view=diff ============================================================================== --- ant/core/trunk/docs/manual/CoreTypes/antlib.html (original) +++ ant/core/trunk/docs/manual/CoreTypes/antlib.html Wed May 31 10:00:15 2006 @@ -8,6 +8,8 @@ <body> <h2><a name="antlib">Antlib</a></h2> + + <h3>Description</h3> <p> An antlib file is an xml file with a root element of "antlib". @@ -44,6 +46,14 @@ <typedef name="scriptpathmapper" classname="org.acme.ant.ScriptPathMapper" onerror="ignore"/> + <macrodef name="print"> + <attribute name="file"/> + <sequential> + <concat taskname="print"> + <fileset dir="." includes="@{file}"/> + </concat> + </sequential> + </macrodef> </antlib> </pre> </blockquote> @@ -81,6 +91,8 @@ </sample:if> </pre> </blockquote> + + <h3><a name="antlibnamespace">Antlib namespace</a></h3> <p> The name space URIs with the pattern <b>antlib:<i>java package</i></b> @@ -127,6 +139,36 @@ The requirement that the resource is in the default classpath may be removed in future versions of Ant.</p> </p> + + + <h3><a name="loadFromInside">Load antlib from inside of the buildfile</a></h3> + <p> + If you want to seperate the antlib from your local Ant installation, e.g. because you + want to hold that jar in your projects SCM system, you have to specify a classpath, so + that Ant could find that jar. The best solution is loading the antlib with <tt><taskdef></tt>. + </p> + <blockquote> + <pre> +<project xmlns:<font color="green">antcontrib</font>="<font color="red">antlib:net.sf.antcontrib</font>"> + <taskdef uri="<font color="red">antlib:net.sf.antcontrib</font>" + resource="net/sf/antcontrib/antlib.xml" + classpath="path/to/ant-contrib.jar"/> + + <target name="iterate"> + <<font color="green">antcontrib</font>:for param="file"> + <fileset dir="."/> + <sequential> + <echo message="- @{file}"/> + </sequential> + </antcontrib:for> + </target> +</project> + </pre> + </blockquote> + + + + <h3><a name="currentnamespace">Current namespace</a></h3> <p> Definitions defined in antlibs may be used in antlibs. However @@ -158,6 +200,8 @@ </antlib> </pre> </blockquote> + + <h3>Other examples and comments</h3> <p> Antlibs may make use of other antlibs. @@ -201,7 +245,7 @@ </blockquote> <hr> -<p align="center">Copyright © 2003-2005 Apache Software +<p align="center">Copyright © 2003-2006 Apache Software Foundation. All rights Reserved.</p> </body> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]