From 82f9f6a1779c25e52234766ef5033c3c87be05fe Mon Sep 17 00:00:00 2001 From: Jan Materne Date: Wed, 31 May 2006 17:00:15 +0000 Subject: [PATCH] Example how to load an Antlib from inside a buildfile. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@410598 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/CoreTasks/typedef.html | 20 ++++++++++++- docs/manual/CoreTypes/antlib.html | 46 +++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/docs/manual/CoreTasks/typedef.html b/docs/manual/CoreTasks/typedef.html index 4ba98a07a..006e39562 100644 --- a/docs/manual/CoreTasks/typedef.html +++ b/docs/manual/CoreTasks/typedef.html @@ -169,6 +169,8 @@ <typedef name="urlset" classname="com.mydomain.URLSet"/> The data type is now available to Ant. The class com.mydomain.URLSet implements this type.

+ +

Assuming a class org.acme.ant.RunnableAdapter that extends Task and implements org.apache.tools.ant.TypeAdapter, @@ -181,6 +183,8 @@ classname="com.acme.ant.RunClock" adapter="org.acme.ant.RunnableAdapter"/> + +

The following fragment shows the use of the classpathref and loaderref to load up two definitions. @@ -200,8 +204,22 @@ loaderref="lib.path.loader" /> + + +

+ If you want to load an antlib into a special xml-namespace, the uri attribute + is important: +

+
+  <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"/>
+  
+ +
-

Copyright © 2001-2005 Apache Software +

Copyright © 2001-2006 Apache Software Foundation. All rights Reserved.

diff --git a/docs/manual/CoreTypes/antlib.html b/docs/manual/CoreTypes/antlib.html index bcd8c09fe..f4d03c121 100644 --- a/docs/manual/CoreTypes/antlib.html +++ b/docs/manual/CoreTypes/antlib.html @@ -8,6 +8,8 @@

Antlib

+ +

Description

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> @@ -81,6 +91,8 @@ </sample:if> + +

Antlib namespace

The name space URIs with the pattern antlib:java package @@ -127,6 +139,36 @@ The requirement that the resource is in the default classpath may be removed in future versions of Ant.

+ + +

Load antlib from inside of the buildfile

+

+ 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 <taskdef>. +

+
+
+<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"/>
+   
+   <target name="iterate">
+      <antcontrib:for param="file">
+         <fileset dir="."/>
+         <sequential>
+            <echo message="- @{file}"/>
+         </sequential>
+      </antcontrib:for>
+   </target>
+</project>
+      
+
+ + + +

Current namespace

Definitions defined in antlibs may be used in antlibs. However @@ -158,6 +200,8 @@ </antlib> + +

Other examples and comments

Antlibs may make use of other antlibs. @@ -201,7 +245,7 @@


-

Copyright © 2003-2005 Apache Software +

Copyright © 2003-2006 Apache Software Foundation. All rights Reserved.