ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Property.java
Date Mon, 08 Jan 2001 12:42:47 GMT
bodewig     01/01/08 04:42:47

  Modified:    .        WHATSNEW
               docs     index.html
               src/main/org/apache/tools/ant/taskdefs Property.java
  Log:
  Add classpath attributes and elements to <property> to specify a
  classpath to load resources from.
  
  Submitted by:	Diane Holt <holtdl@yahoo.com>
  
  Revision  Changes    Path
  1.65      +3 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- WHATSNEW	2001/01/04 13:48:50	1.64
  +++ WHATSNEW	2001/01/08 12:42:45	1.65
  @@ -54,6 +54,9 @@
   * Added nested format elements to the tstamp task allowing additional time 
     formats to be defined for arbitrary properties.   
   
  +* Added classpath attribute and nested classpath element to <property>
  +  to make the resource attribute more powerful.
  +
   Fixed bugs:
   -----------
   
  
  
  
  1.180     +18 -1     jakarta-ant/docs/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/index.html,v
  retrieving revision 1.179
  retrieving revision 1.180
  diff -u -r1.179 -r1.180
  --- index.html	2001/01/04 13:48:50	1.179
  +++ index.html	2001/01/08 12:42:46	1.180
  @@ -29,7 +29,7 @@
   </ul>
   
   <p>Version: @VERSION@</p>
  -<p>$Id: index.html,v 1.179 2001/01/04 13:48:50 conor Exp $</p>
  +<p>$Id: index.html,v 1.180 2001/01/08 12:42:46 bodewig Exp $</p>
   
   <hr>
   <h2>Table of Contents</h2>
  @@ -3954,7 +3954,24 @@
         current platforms conventions). Otherwise it is taken as a path
         relative to the project's basedir and expanded.</td>
     </tr>
  +  <tr>
  +    <td valign="top">classpath</td> 
  +    <td valign="top">the classpath to use when looking up a resource.</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">classpathref</td> 
  +    <td valign="top">the classpath to use when looking up a resource,
  +      given as <a href="#references">reference</a> to a PATH defined
  +      elsewhere..</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
   </table>
  +<h3>Parameters specified as nested elements</h3>
  +<h4>classpath</h4>
  +<p><code>Property</code>'s <em>classpath</em> attribute is
a <a
  +href="#path">PATH like structure</a> and can also be set via a nested
  +<em>classpath</em> element.</p>
   <h3>Examples</h3>
   <pre>  &lt;property name=&quot;foo.dist&quot; value=&quot;dist&quot;
/&gt;</pre>
   <p>sets the property <code>foo.dist</code> to the value &quot;dist&quot;.</p>
  
  
  
  1.24      +28 -1     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Property.java	2000/12/07 00:45:22	1.23
  +++ Property.java	2001/01/08 12:42:47	1.24
  @@ -55,6 +55,7 @@
   package org.apache.tools.ant.taskdefs;
   
   import org.apache.tools.ant.*;
  +import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
   import java.io.*;
   import java.util.*;
  @@ -73,6 +74,7 @@
       protected String value;
       protected File file;
       protected String resource;
  +    protected Path classpath;
       protected String env;
       protected Reference ref = null;
   
  @@ -130,6 +132,25 @@
           return env;
       }
   
  +    public void setClasspath(Path classpath) {
  +        if (this.classpath == null) {
  +            this.classpath = classpath;
  +        } else {
  +            this.classpath.append(classpath);
  +        }
  +    }
  +    
  +    public Path createClasspath() {
  +        if (this.classpath == null) {
  +            this.classpath = new Path(project);
  +        }
  +        return this.classpath.createPath();
  +    }
  +    
  +    public void setClasspathRef(Reference r) {
  +        createClasspath().setRefid(r);
  +    }
  +
       public void setUserProperty(boolean userProperty) {
           this.userProperty = userProperty;
       }
  @@ -189,8 +210,14 @@
           Properties props = new Properties();
           log("Resource Loading " + name, Project.MSG_VERBOSE);
           try {
  -            ClassLoader cL = this.getClass().getClassLoader();
  +            ClassLoader cL = null; 
               InputStream is = null;
  +
  +            if (classpath != null) { 
  +                cL = new AntClassLoader(project, classpath, false); 
  +            } else { 
  +                cL = this.getClass().getClassLoader(); 
  +            } 
   
               if (cL == null) {
                   is = ClassLoader.getSystemResourceAsStream(name);
  
  
  

Mime
View raw message