From d70334b86345e4f20005223a544802cfdfd82159 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Fri, 29 Dec 2006 14:15:27 +0000 Subject: [PATCH] Bugzilla 41158: add classpathref to git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@491018 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 + docs/manual/CoreTasks/whichresource.html | 289 ++++++------------ .../tools/ant/taskdefs/WhichResource.java | 10 + 3 files changed, 113 insertions(+), 189 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 8a12b32b1..a6c217b1b 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -28,6 +28,9 @@ Other changes: * add errorProperty and updatedProperty to Bugzilla 35637 and 28941. +* add classpathref attribute to + Bugzilla 41158. + Changes from Ant 1.6.5 to Ant 1.7.0 =================================== diff --git a/docs/manual/CoreTasks/whichresource.html b/docs/manual/CoreTasks/whichresource.html index cf6e6c411..d5e62e087 100644 --- a/docs/manual/CoreTasks/whichresource.html +++ b/docs/manual/CoreTasks/whichresource.html @@ -16,194 +16,105 @@ --> - - - Whichresource - Task - - - - - - - - - - - - - - - - - -
- - - -
- Whichresource - Task -
Find a class or resource on the supplied classpath, or the system classpath if none is supplied. -
- - - Apache Ant - -
-
- - - - - - - - - - + + + + Whichresource Task + + + + + + +

Whichresource

+

Description

+

+ Find a class or resource on the supplied classpath, or the + system classpath if none is supplied. + The named property is set if the item can be found. + For example: +

+
+  <whichresource resource="/log4j.properties" property="log4j.url" >
+
+

Parameters

+
 
- - - Description -
- Find a class or resource on the supplied classpath, or the system classpath if none is supplied. The named property is set if the item can be found. For example
 <whichresource resource="/log4j.properties" property="log4j.url" > 
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
property + The property to fill with the URL of the resource of class. + Yes
class + The name of the class to look for. + Exactly one of these.
resource + The name of the resource to look for. +
classpath + The classpath to use when looking up class + or resource. + No
classpathref + The classpath to use, given as a + reference + to a path defined elsewhere. + Since Ant 1.7.1. + No
- - - - - - - - - - - - -
 
- - - Parameters -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Attribute - - Description - - Type - - Requirement -
- property - - the property to fill with the URL of the resource or class - - String - - Required -
- class - - name the class to look for - - String - - Exactly one of these two -
- resource - - name the resource to look for - - String -
- classpath - - Set the classpath to be used for this compilation. - - Path - - Optional -
-
- - - - - - - - - - -
 
- - - Parameters as nested elements -
- - - - - -
 
- - classpath (org.apache.tools.ant.types.Path) -
- Adds a path to the classpath. - - - -
- - -
- - - -
- - +

Parameters specified as nested elements

+

classpath

+

+ Whichresource's classpath attribute is a + path-like structure and can also be + set via a nested <classpath> element. +

+

Examples

+

+ The following shows using a classpath reference. +

+
+  <path id="bsf.classpath">
+    <fileset dir="${user.home}/lang/bsf" includes="*.jar"/>
+  </path>
+  <whichresource property="bsf.class.location"
+                 class="org.apache.bsf.BSFManager"
+                 classpathref="bsf.classpath"/>
+  <echo>${bsf.class.location}</echo>
+
+

+ The following shows using a nested classpath. +

+
+  <whichresource
+    property="ant-contrib.antlib.location"
+    resource="net/sf/antcontrib/antlib.xml">
+    <classpath>
+      <path path="f:/testing/ant-contrib/target/ant-contrib.jar"/>
+    </classpath>
+  </whichresource>
+  <echo>${ant-contrib.antlib.location}</echo>
+
+ diff --git a/src/main/org/apache/tools/ant/taskdefs/WhichResource.java b/src/main/org/apache/tools/ant/taskdefs/WhichResource.java index 579477373..e24819ba4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/WhichResource.java +++ b/src/main/org/apache/tools/ant/taskdefs/WhichResource.java @@ -19,6 +19,7 @@ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; @@ -82,6 +83,15 @@ public class WhichResource extends Task { return classpath.createPath(); } + /** + * Set the classpath to use by reference. + * + * @param r a reference to an existing classpath. + * @since Ant 1.7.1 + */ + public void setClasspathRef(Reference r) { + createClasspath().setRefid(r); + } /** * validate