You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by st...@locus.apache.org on 2000/02/13 19:20:01 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Copydir.java Copyfile.java FixCRLF.java Java.java Javac.java Javadoc.java KeySubst.java Rmic.java defaults.properties

stefano     00/02/13 10:20:01

  Modified:    docs     index.html
               src/main/org/apache/tools/ant Project.java
                        ProjectHelper.java Target.java Task.java
               src/main/org/apache/tools/ant/taskdefs Copydir.java
                        Copyfile.java FixCRLF.java Java.java Javac.java
                        Javadoc.java KeySubst.java Rmic.java
                        defaults.properties
  Log:
  Several changes:
  
  1)  restructured Project and Task: copyFile should be a project
  method rather than a task method for good OO patterns. Well,
  actually they should be target-granular but we'll see.
  
  2)  patched all the necessary files to make the above work
  
  3)  removed some unused methods (setAttributes())
  
  4)  added the Filter task that addes token filtering capabilities
  to all the copyFile operations. This works more or less as a
  superstructure to Replace and KeySubst but automatically and
  inherited by all the tasks that use copyFile() methods.
  
  5)  indicated KeySubst as deprecated
  
  6) updated docs to reflect this new behavior
  
  NOTE: behavior is _totally_ back compatible if you don't
  specify any <filter> tag.
  
  NOTE2: nothing is carved in stone. If you don't like something
  you're welcome to propose fixes.
  
  Revision  Changes    Path
  1.9       +63 -11    jakarta-ant/docs/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/index.html,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- index.html	2000/02/12 16:59:25	1.8
  +++ index.html	2000/02/13 18:19:58	1.9
  @@ -11,12 +11,14 @@
   <p>by</p>
   <!-- Names are in alphabetical order, on last name -->
   <ul>
  -  <li>James Duncan Davison (<a href="mailto:(duncan@x180.com">duncan@x180.com</a>)</li>
  -  <li>Arnout J. Kuiper (<a href="mailto:(ajkuiper@wxs.nl">ajkuiper@wxs.nl</a>)</li>
  -  <li>Stefano Mazzocchi (<a href="mailto:(stefano@apache.org">stefano@apache.org</a>)</li>
  -  <li>Sam Ruby (<a href="mailto:(rubys@us.ibm.com">rubys@us.ibm.com</a>)</li>
  +  <li>James Duncan Davison (<a href="mailto:duncan@x180.com">duncan@x180.com</a>)</li>
  +  <li>Arnout J. Kuiper (<a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a>)</li>
  +  <li>Stefano Mazzocchi (<a href="mailto:stefano@apache.org">stefano@apache.org</a>)</li>
  +  <li>Sam Ruby (<a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>)</li>
   </ul>
  -<p>Version 1.0.5 - 2000/02/12</p>
  +
  +<p>Version 1.0.6 - 2000/02/13</p>
  +
   <hr>
   <h2>Table of Contents</h2>
   <ul>
  @@ -296,6 +298,22 @@
   <p>If there is a property called &quot;builddir&quot; with the value
   &quot;build&quot;, then this could be used in an attribute like this: &quot;${builddir}/classes&quot;.
   This is resolved as &quot;build/classes&quot;.</p>
  +<h3>Token Filters</h3>
  +<p>A project can have a set of tokens that will be automatically expanded if
  +found when a file is copied. These might be set in the buildfile
  +by the <a href="#filter">filter task</a>. If no filter task is specified, all
  +file copying works normally and the files are not modified during the copy in
  +any way. Otherwise, if a filter is set, the files will be <i>filtered</i> and
  +each occurrency of the specified token will be replaced.</p>
  +<p>Since this can be a very harmful behavior, the tokens in the files <b>must</b>
  +be of the form<i> @token@</i> where <i>token</i> is the token name that is set
  +in the filter task. This token syntax matches the syntax of other build systems
  +that perform such filtering and remains sufficiently orthogonal to most
  +programming and scripting languages, as well with documentation systems.</p>
  +<p>Note: in case a token with the format @token@ if found in a file but no
  +filter is associated with that token, no changes take place. So, no escaping
  +method is present, but as long as you choose appropriate names for your tokens,
  +this should not cause problems.</p>
   <h3>Examples</h3>
   <blockquote>
     <pre>&lt;project name=&quot;foo&quot; default=&quot;dist&quot; basedir=&quot;.&quot;&gt;
  @@ -303,6 +321,8 @@
       &lt;tstamp/&gt;
       &lt;property name=&quot;build&quot; value=&quot;build&quot; /&gt;
       &lt;property name=&quot;dist&quot;  value=&quot;dist&quot; /&gt;
  +    &lt;filter token=&quot;version&quot; value=&quot;1.0.3&quot; /&gt;
  +    &lt;filter token=&quot;year&quot; value=&quot;2000&quot; /&gt;
     &lt;/target&gt;
   
     &lt;target name=&quot;prepare&quot; depends=&quot;init&quot;&gt;
  @@ -429,6 +449,7 @@
     <li><a href="#echo">Echo</a></li>
     <li><a href="#exec">Exec</a></li>
     <li><a href="#expand">Expand</a></li>
  +  <li><a href="#filter">Filter</a></li>
     <li><a href="#get">Get</a></li>
     <li><a href="#gzip">GZip</a></li>
     <li><a href="#fixcrlf">FixCRLF</a></li>
  @@ -842,6 +863,37 @@
     /&gt;</code></p>
   </blockquote>
   <hr>
  +<h2><a name="filter">Filter</a></h2>
  +<h3>Description</h3>
  +<p>Sets a token filter for this project. Token filters are used by all tasks
  +that perform file copying operations through the Project commodity methods.</p>
  +<p>Note: the token string must not contain the separators chars (@).</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">token</td>
  +    <td valign="top">the token string without @</td>
  +    <td align="center" valign="top">Yes</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">value</td>
  +    <td valign="top">the string that should be put to replace the token when the
  +      file is copied</td>
  +    <td align="center" valign="top">Yes</td>
  +  </tr>
  +</table>
  +<h3>Examples</h3>
  +<pre>  &lt;filter token=&quot;year&quot; value=&quot;2000&quot; /&gt;
  +  &lt;copydir src=&quot;${src.dir}&quot; dest=&quot;${dest.dir}&quot;/&gt;</pre>
  +<p>will copy recursively all the files from the <i>src.dir</i> directory into
  +the <i>dest.dir</i> directory replacing all the occurencies of the string <i>@year@</i>
  +with <i>2000.</i></p>
  +<hr>
   <h2><a name="get">Get</a></h2>
   <h3>Description</h3>
   <p>Gets a file from an URL. When the verbose option is &quot;on&quot;, this task
  @@ -957,7 +1009,7 @@
     </tr>
     <tr>
       <td valign="top">tab</td>
  -    <td valign="top">Specifies how tab characters are to be handled.  Valid 
  +    <td valign="top">Specifies how tab characters are to be handled.  Valid
         values for this property are:
         <ul>
         <li>add: convert sequences of spaces which span a tab stop to tabs
  @@ -973,10 +1025,10 @@
     </tr>
     <tr>
       <td valign="top">eof</td>
  -    <td valign="top">Specifies how DOS end of file (control-Z) characters are 
  +    <td valign="top">Specifies how DOS end of file (control-Z) characters are
         to be handled.  Valid values for this property are:
         <ul>
  -      <li>add: ensure that there is an EOF character at the end of the file 
  +      <li>add: ensure that there is an EOF character at the end of the file
         <li>asis: leave EOF characters alone
         <li>remove: remove any EOF character found at the end
         </ul>
  @@ -993,13 +1045,13 @@
          includes=&quot;**/*.sh&quot;
     /&gt;</pre>
   <p>Removes carriage return and eof characters from the shell scripts.  Tabs and
  -spaces are left as is. 
  +spaces are left as is.
   <pre>  &lt;fixcrlf srcdir=&quot;${src}&quot;
          cr="add"
          includes=&quot;**/*.bat&quot;
     /&gt;</pre>
   <p>Ensures that there are carriage return characters prior to evey line feed.
  -Tabs and spaces are left as is.  
  +Tabs and spaces are left as is.
   EOF characters are left alone if run on
   DOS systems, and are removed if run on Unix systems.</p>
   <pre>  &lt;fixcrlf srcdir=&quot;${src}&quot;
  @@ -1007,7 +1059,7 @@
          includes=&quot;**/Makefile&quot;
     /&gt;</pre>
   <p>Adds or removes CR characters to match local OS conventions, and
  -converts spaces to tabs when appropriate.  EOF characters are left alone if 
  +converts spaces to tabs when appropriate.  EOF characters are left alone if
   run on DOS systems, and are removed if run on Unix systems.
   Many versions of make require tabs prior to commands.</p>
   <pre>  &lt;fixcrlf srcdir=&quot;${src}&quot;
  
  
  
  1.8       +160 -30   jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Project.java	2000/02/11 01:32:54	1.7
  +++ Project.java	2000/02/13 18:19:59	1.8
  @@ -89,6 +89,9 @@
       public static final String JAVA_1_2 = "1.2";
       public static final String JAVA_1_3 = "1.3";
   
  +    public static final String TOKEN_START = "@";
  +    public static final String TOKEN_END = "@";
  +
       private String name;
       private PrintStream out;
       private int msgOutputLevel = MSG_INFO;
  @@ -98,6 +101,8 @@
       private String defaultTarget;
       private Hashtable taskClassDefinitions = new Hashtable();
       private Hashtable targets = new Hashtable();
  +    private Hashtable filters = new Hashtable();
  +    private boolean filtering = false;
       private File baseDir;
   
       public Project(PrintStream out, int msgOutputLevel) {
  @@ -114,9 +119,10 @@
               InputStream in = this.getClass().getResourceAsStream(defs);
               props.load(in);
               in.close();
  +
               Enumeration enum = props.propertyNames();
               while (enum.hasMoreElements()) {
  -                String key = (String)enum.nextElement();
  +                String key = (String) enum.nextElement();
                   String value = props.getProperty(key);
                   try {
                       Class taskClass = Class.forName(value);
  @@ -127,10 +133,11 @@
               }
   
               Properties systemP = System.getProperties();
  -            Enumeration e=systemP.keys();
  +            Enumeration e = systemP.keys();
               while (e.hasMoreElements()) {
  -                String n=(String) e.nextElement();
  -                properties.put(n, systemP.get(n));
  +                String name = (String) e.nextElement();
  +                String value = (String) systemP.get(name);
  +                this.setProperty(name, value);
               }
           } catch (IOException ioe) {
               String msg = "Can't load default task list";
  @@ -142,11 +149,11 @@
       public PrintStream getOutput() {
           return this.out;
       }
  -    
  +
       public int getOutputLevel() {
           return this.msgOutputLevel;
       }
  -    
  +
       public void log(String msg) {
           log(msg, MSG_INFO);
       }
  @@ -167,13 +174,13 @@
           // command line properties take precedence
           if (null != userProperties.get(name))
               return;
  -        log("Setting project property: " + name + " to " +
  +        log("Setting project property: " + name + " -> " +
               value, MSG_VERBOSE);
           properties.put(name, value);
       }
   
       public void setUserProperty(String name, String value) {
  -        log("Setting project property: " + name + " to " +
  +        log("Setting project property: " + name + " -> " +
               value, MSG_VERBOSE);
           userProperties.put(name, value);
           properties.put(name, value);
  @@ -211,6 +218,18 @@
           return name;
       }
   
  +    public void addFilter(String token, String value) {
  +        if (token == null) return;
  +        log("Setting token to filter: " + token + " -> "
  +            + value, MSG_VERBOSE);
  +        this.filters.put(token, value);
  +        this.filtering = true;
  +    }
  +
  +    public Hashtable getFilters() {
  +        return filters;
  +    }
  +
       // match basedir attribute in xml
       public void setBasedir(String baseD) throws BuildException {
           try {
  @@ -330,28 +349,29 @@
       public void addOrReplaceTarget(String targetName, Target target) {
           String msg = " +Target: " + targetName;
           log(msg, MSG_VERBOSE);
  +        target.setProject(this);
           targets.put(targetName, target);
       }
   
       public Task createTask(String taskType) throws BuildException {
           Class c = (Class)taskClassDefinitions.get(taskType);
  -	
  +
           // XXX
           // check for nulls, other sanity
   
           try {
               Object o=c.newInstance();
  -	    Task task = null;
  -	    if( o instanceof Task ) {
  -	       task=(Task)o;
  -	    } else {
  -		// "Generic" Bean - use the setter pattern
  -		// and an Adapter
  -		TaskAdapter taskA=new TaskAdapter();
  -		taskA.setProxy( o );
  -		task=taskA;
  -	    }
  -	    task.setProject(this);
  +            Task task = null;
  +            if( o instanceof Task ) {
  +               task=(Task)o;
  +            } else {
  +                // "Generic" Bean - use the setter pattern
  +                // and an Adapter
  +                TaskAdapter taskA=new TaskAdapter();
  +                taskA.setProxy( o );
  +                task=taskA;
  +            }
  +            task.setProject(this);
               String msg = "   +Task: " + taskType;
               log (msg, MSG_VERBOSE);
               return task;
  @@ -359,7 +379,7 @@
               String msg = "Could not create task of type: "
                    + taskType + " due to " + e;
               throw new BuildException(msg);
  -    }
  +        }
       }
   
       public void executeTarget(String targetName) throws BuildException {
  @@ -455,9 +475,8 @@
           @returns translated string or empty string if to_process is null or empty
           @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
       */
  -    public static String translatePath(String to_process) {
  -        if ( to_process == null || to_process.length() == 0 )
  -            return "";
  +    public String translatePath(String to_process) {
  +        if ( to_process == null || to_process.length() == 0 ) return "";
   
           StringBuffer bs = new StringBuffer(to_process.length() + 50);
           StringCharacterIterator sci = new StringCharacterIterator(to_process);
  @@ -484,15 +503,127 @@
           }
           return(bs.toString());
       }
  +
  +    /**
  +     * Convienence method to copy a file from a source to a destination
  +     * using token filtering.
  +     *
  +     * @throws IOException
  +     */
  +    public void copyFile(String sourceFile, String destFile)
  +        throws IOException
  +    {
  +        copyFile(new File(sourceFile), new File(destFile));
  +    }
  +
  +    /**
  +     * Convienence method to copy a file from a source to a destination
  +     * specifying if token filtering must be used.
  +     *
  +     * @throws IOException
  +     */
  +    public void copyFile(File sourceFile, File destFile)
  +        throws IOException
  +    {
  +
  +        if (destFile.lastModified() < sourceFile.lastModified()) {
  +            log("Copy: " + sourceFile.getAbsolutePath() + " > "
  +                    + destFile.getAbsolutePath(), MSG_VERBOSE);
  +
  +            // ensure that parent dir of dest file exists!
  +            // not using getParentFile method to stay 1.1 compat
  +            File parent = new File(destFile.getParent());
  +            if (!parent.exists()) {
  +                parent.mkdirs();
  +            }
   
  -    // returns the boolean equivalent of a string, which is considered true
  -    // if either "on", "true", or "yes" is found, case insensitiveness.
  +            if (filtering) {
  +                BufferedReader in = new BufferedReader(new FileReader(sourceFile));
  +                BufferedWriter out = new BufferedWriter(new FileWriter(destFile));
  +
  +                int length;
  +                String newline = null;
  +                String line = in.readLine();
  +                while (line != null) {
  +                    if (line.length() == 0) {
  +                        out.newLine();
  +                    } else {
  +                        newline = replace(line, filters);
  +                        out.write(newline);
  +                        out.newLine();
  +                    }
  +                    line = in.readLine();
  +                }
  +
  +                out.close();
  +                in.close();
  +            } else {
  +                FileInputStream in = new FileInputStream(sourceFile);
  +                FileOutputStream out = new FileOutputStream(destFile);
  +
  +                byte[] buffer = new byte[8 * 1024];
  +                int count = 0;
  +                do {
  +                    out.write(buffer, 0, count);
  +                    count = in.read(buffer, 0, buffer.length);
  +                } while (count != -1);
  +
  +                in.close();
  +                out.close();
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Does replacement on the given string using the given token table.
  +     *
  +     * @returns the string with the token replaced.
  +     */
  +    private String replace(String s, Hashtable tokens) {
  +        int index = s.indexOf(TOKEN_START);
  +
  +        if (index > -1) {
  +            try {
  +                StringBuffer b = new StringBuffer();
  +                int i = 0;
  +                String token = null;
  +                String value = null;
  +
  +                do {
  +                    token = s.substring(index + TOKEN_START.length(), s.indexOf(TOKEN_END, index + TOKEN_START.length() + 1));
  +                    b.append(s.substring(i, index));
  +                    if (tokens.containsKey(token)) {
  +                        value = (String) tokens.get(token);
  +                        log("Replacing: " + TOKEN_START + token + TOKEN_END + " -> " + value, MSG_VERBOSE);
  +                        b.append(value);
  +                    } else {
  +                        b.append(TOKEN_START);
  +                        b.append(token);
  +                        b.append(TOKEN_END);
  +                    }
  +                    i = index + TOKEN_START.length() + token.length() + TOKEN_END.length();
  +                } while ((index = s.indexOf(TOKEN_START, i)) > -1);
  +
  +                b.append(s.substring(i));
  +                return b.toString();
  +            } catch (StringIndexOutOfBoundsException e) {
  +                return s;
  +            }
  +        } else {
  +            return s;
  +        }
  +    }
  +
  +    /**
  +     * returns the boolean equivalent of a string, which is considered true
  +     * if either "on", "true", or "yes" is found, ignoring case.
  +     */
       public static boolean toBoolean(String s) {
  -        return (s.equalsIgnoreCase("on") || 
  -                s.equalsIgnoreCase("true") || 
  +        return (s.equalsIgnoreCase("on") ||
  +                s.equalsIgnoreCase("true") ||
                   s.equalsIgnoreCase("yes"));
       }
  -    
  +
       // Given a string defining a target name, and a Hashtable
       // containing the "name to Target" mapping, pick out the
       // Target and execute it.
  @@ -506,7 +637,6 @@
           log("Executing Target: "+target, MSG_INFO);
           t.execute();
       }
  -
   
       /**
        * Topologically sort a set of Targets.
  
  
  
  1.4       +1 -0      jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java
  
  Index: ProjectHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProjectHelper.java	2000/02/11 01:32:54	1.3
  +++ ProjectHelper.java	2000/02/13 18:19:59	1.4
  @@ -227,6 +227,7 @@
                       NamedNodeMap nodeMap = element.getAttributes();
                       configureTask(project, task, nodeMap);
                       task.init();
  +                    task.setTarget(target);
                       target.addTask(task);
                   }
               }
  
  
  
  1.3       +2 -8      jakarta-ant/src/main/org/apache/tools/ant/Target.java
  
  Index: Target.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Target.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Target.java	2000/02/11 01:32:54	1.2
  +++ Target.java	2000/02/13 18:19:59	1.3
  @@ -88,12 +88,6 @@
           }
       }
   
  -    public void setAttribute(String name, Object value) {
  -        if (value instanceof Task) {
  -            addTask((Task) value);
  -        }
  -    }
  -
       public void setName(String name) {
           this.name = name;
       }
  @@ -115,11 +109,11 @@
       }
   
       public void setCondition(String property) {
  -        this.condition = property;
  +        this.condition = (property == null) ? "" : property;
       }
   
       public void execute() throws BuildException {
  -        if ((this.condition != null) || (this.condition.equals("")) || (project.getProperty(this.condition) != null)) {
  +        if (("".equals(this.condition)) || (project.getProperty(this.condition) != null)) {
               Enumeration enum = tasks.elements();
               while (enum.hasMoreElements()) {
                   Task task = (Task) enum.nextElement();
  
  
  
  1.3       +5 -57     jakarta-ant/src/main/org/apache/tools/ant/Task.java
  
  Index: Task.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Task.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Task.java	2000/02/11 01:32:54	1.2
  +++ Task.java	2000/02/13 18:19:59	1.3
  @@ -54,14 +54,10 @@
   
   package org.apache.tools.ant;
   
  -import java.io.*;
  -import java.util.*;
  -
   /**
    * Base class for all tasks.
  - *
  - * @author duncan@x180.com
    */
  + 
   public abstract class Task {
   
       protected Project project = null;
  @@ -80,16 +76,12 @@
       }
   
       /**
  -     * Sets a task attribute.
  +     * Sets the target object of this task.
        *
  -     * @param name the attribute name
  -     * @param value the attribute value
  +     * @param target Target in whose scope this task belongs.
        */
  -    public void setAttribute(String name, Object value) {
  -        if (name.equals("target")) {
  -            this.target = (Target) value;
  -            this.project = this.target.getProject();
  -        }
  +    public void setTarget(Target target) {
  +        this.target = target;
       }
   
       /**
  @@ -106,49 +98,5 @@
        */
       public void execute() throws BuildException {};
   
  -    /**
  -     * Convienence method to copy a file from a source to a destination
  -     *
  -     * @throws IOException
  -     */
  -    protected void copyFile(String sourceFile, String destFile)
  -        throws IOException
  -    {
  -        copyFile(new File(sourceFile), new File(destFile));
  -    }
  -
  -    /**
  -     * Convienence method to copy a file from a source to a destination.
  -     *
  -     * @throws IOException
  -     */
  -    protected void copyFile(File sourceFile, File destFile) throws IOException {
  -
  -        if (destFile.lastModified() < sourceFile.lastModified()) {
  -            project.log("Copy: " + sourceFile.getAbsolutePath() + " > "
  -                    + destFile.getAbsolutePath(), project.MSG_VERBOSE);
  -
  -            // ensure that parent dir of dest file exists!
  -            // not using getParentFile method to stay 1.1 compat
  -            File parent = new File(destFile.getParent());
  -            if (!parent.exists()) {
  -                parent.mkdirs();
  -            }
  -
  -            // open up streams and copy using a decent buffer
  -            FileInputStream in = new FileInputStream(sourceFile);
  -            FileOutputStream out = new FileOutputStream(destFile);
  -
  -            byte[] buffer = new byte[8 * 1024];
  -            int count = 0;
  -            do {
  -                out.write(buffer, 0, count);
  -                count = in.read(buffer, 0, buffer.length);
  -            } while (count != -1);
  -
  -            in.close();
  -            out.close();
  -        }
  -    }
   }
   
  
  
  
  1.5       +3 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copydir.java
  
  Index: Copydir.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copydir.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Copydir.java	2000/02/09 20:51:47	1.4
  +++ Copydir.java	2000/02/13 18:20:00	1.5
  @@ -97,10 +97,10 @@
                           + destDir.getAbsolutePath());
               Enumeration enum = filecopyList.keys();
               while (enum.hasMoreElements()) {
  -                String fromFile = (String)enum.nextElement();
  -                String toFile = (String)filecopyList.get(fromFile);
  +                String fromFile = (String) enum.nextElement();
  +                String toFile = (String) filecopyList.get(fromFile);
                   try {
  -                    copyFile(fromFile, toFile);
  +                    project.copyFile(fromFile, toFile);
                   } catch (IOException ioe) {
                       String msg = "Failed to copy " + fromFile + " to " + toFile
                           + " due to " + ioe.getMessage();
  
  
  
  1.2       +17 -17    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copyfile.java
  
  Index: Copyfile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copyfile.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Copyfile.java	2000/01/13 10:41:41	1.1
  +++ Copyfile.java	2000/02/13 18:20:00	1.2
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -9,7 +9,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -17,15 +17,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowlegement may appear in the software itself,
    *    if and wherever such third-party acknowlegements normally appear.
    *
    * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
    *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written 
  + *    from this software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache"
  @@ -60,8 +60,8 @@
   import java.util.*;
   
   /**
  + * Copies a file.
    *
  - *
    * @author duncan@x180.com
    */
   
  @@ -71,22 +71,22 @@
       public File destFile;
   
       public void setSrc(String src) {
  -	srcFile = project.resolveFile(src);
  +        srcFile = project.resolveFile(src);
       }
   
       public void setDest(String dest) {
  -	destFile = project.resolveFile(dest);
  +        destFile = project.resolveFile(dest);
       }
   
       public void execute() throws BuildException {
  -	if (srcFile.lastModified() > destFile.lastModified()) {
  -	    try {
  -		copyFile(srcFile, destFile);
  -	    } catch (IOException ioe) {
  -		String msg = "Error copying file: " + srcFile.getAbsolutePath()
  -		    + " due to " + ioe.getMessage();
  -		throw new BuildException(msg);
  -	    }
  -	}
  +        if (srcFile.lastModified() > destFile.lastModified()) {
  +            try {
  +                project.copyFile(srcFile, destFile);
  +            } catch (IOException ioe) {
  +                String msg = "Error copying file: " + srcFile.getAbsolutePath()
  +                    + " due to " + ioe.getMessage();
  +                throw new BuildException(msg);
  +            }
  +        }
       }
   }
  
  
  
  1.3       +125 -122  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  
  Index: FixCRLF.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FixCRLF.java	2000/02/12 22:19:18	1.2
  +++ FixCRLF.java	2000/02/13 18:20:00	1.3
  @@ -60,8 +60,8 @@
   import java.text.*;
   
   /**
  - * Task to convert text source files to local OS formatting conventions, as 
  - * well as repair text files damaged by misconfigured or misguided editors or 
  + * Task to convert text source files to local OS formatting conventions, as
  + * well as repair text files damaged by misconfigured or misguided editors or
    * file transfer programs.
    * <p>
    * This task can take the following arguments:
  @@ -210,16 +210,16 @@
           if (!srcDir.exists()) {
               throw new BuildException("srcdir does not exist!");
           }
  -	if (!srcDir.isDirectory()) {
  +        if (!srcDir.isDirectory()) {
               throw new BuildException("srcdir is not a directory!");
           }
           if (destDir != null) {
               if (!destDir.exists()) {
  -		throw new BuildException("destdir does not exist!");
  +                throw new BuildException("destdir does not exist!");
               }
  -	    if (!destDir.isDirectory()) {
  -		throw new BuildException("destdir is not a directory!");
  -	    }
  +            if (!destDir.isDirectory()) {
  +                throw new BuildException("destdir is not a directory!");
  +            }
           }
   
           // log options used
  @@ -231,134 +231,137 @@
   
           DirectoryScanner ds = super.getDirectoryScanner(srcDir);
           String[] files = ds.getIncludedFiles();
  -try {
  -
  -        for (int i = 0; i < files.length; i++) {
  -            File srcFile = new File(srcDir, files[i]);
   
  -            // read the contents of the file
  -            int count = (int)srcFile.length();
  -            byte indata[] = new byte[count];
  -            try {
  -                FileInputStream inStream = new FileInputStream(srcFile);
  -                inStream.read(indata);
  -                inStream.close();
  -            } catch (IOException e) {
  -                throw new BuildException(e);
  -            }
  +        try {
  +            for (int i = 0; i < files.length; i++) {
  +                File srcFile = new File(srcDir, files[i]);
  +
  +                // read the contents of the file
  +                int count = (int)srcFile.length();
  +                byte indata[] = new byte[count];
  +                try {
  +                    FileInputStream inStream = new FileInputStream(srcFile);
  +                    inStream.read(indata);
  +                    inStream.close();
  +                } catch (IOException e) {
  +                    throw new BuildException(e);
  +                }
   
  -            // count the number of cr, lf,  and tab characters
  -            int cr = 0;
  -            int lf = 0;
  -            int tab = 0;
  -
  -            for (int k=0; k<count; k++) {
  -                byte c = indata[k];
  -                if (c == '\r') cr++;
  -                if (c == '\n') lf++;
  -                if (c == '\t') tab++;
  -            }
  +                // count the number of cr, lf,  and tab characters
  +                int cr = 0;
  +                int lf = 0;
  +                int tab = 0;
  +
  +                for (int k=0; k<count; k++) {
  +                    byte c = indata[k];
  +                    if (c == '\r') cr++;
  +                    if (c == '\n') lf++;
  +                    if (c == '\t') tab++;
  +                }
   
  -            // check for trailing eof
  -            boolean eof = ((count>0) && (indata[count-1] == 0x1A));
  +                // check for trailing eof
  +                boolean eof = ((count>0) && (indata[count-1] == 0x1A));
   
  -            // log stats (before fixes)
  -            project.log(srcFile + ": size=" + count + " cr=" + cr +
  -                        " lf=" + lf + " tab=" + tab + " eof=" + eof,
  -                        "fixcrlf", project.MSG_VERBOSE);
  -
  -            // determine the output buffer size (slightly pessimisticly)
  -            int outsize = count;
  -            if (addcr  !=  0) outsize-=cr;
  -            if (addcr  == +1) outsize+=lf;
  -            if (addtab == -1) outsize+=tab*7;
  -            if (ctrlz  == +1) outsize+=1;
  -
  -            // copy the data
  -            byte outdata[] = new byte[outsize];
  -            int o = 0;    // output offset
  -            int line = o; // beginning of line
  -            int col = 0;  // desired column
  -
  -            for (int k=0; k<count; k++) {
  -                switch (indata[k]) {
  -                    case ' ':
  -                        // advance column
  -                        if (addtab == 0) outdata[o++]=(byte)' ';
  -                        col++;
  -                        break;
  -
  -                    case '\t':
  -                        if (addtab == 0) {
  -                            // treat like any other character
  -                            outdata[o++]=(byte)'\t';
  -                            col++;
  -                        } else {
  -                            // advance column to next tab stop
  -                            col = (col|7)+1;
  -                        }
  -                        break;
  -
  -                    case '\r':
  -                        if (addcr == 0) {
  -                            // treat like any other character
  -                            outdata[o++]=(byte)'\r';
  +                // log stats (before fixes)
  +                project.log(srcFile + ": size=" + count + " cr=" + cr +
  +                            " lf=" + lf + " tab=" + tab + " eof=" + eof,
  +                            "fixcrlf", project.MSG_VERBOSE);
  +
  +                // determine the output buffer size (slightly pessimisticly)
  +                int outsize = count;
  +                if (addcr  !=  0) outsize-=cr;
  +                if (addcr  == +1) outsize+=lf;
  +                if (addtab == -1) outsize+=tab*7;
  +                if (ctrlz  == +1) outsize+=1;
  +
  +                // copy the data
  +                byte outdata[] = new byte[outsize];
  +                int o = 0;    // output offset
  +                int line = o; // beginning of line
  +                int col = 0;  // desired column
  +
  +                for (int k=0; k<count; k++) {
  +                    switch (indata[k]) {
  +                        case ' ':
  +                            // advance column
  +                            if (addtab == 0) outdata[o++]=(byte)' ';
                               col++;
  -                        }
  -                        break;
  +                            break;
   
  -                    case '\n':
  -                        // start a new line (optional CR followed by LF)
  -                        if (addcr == +1) outdata[o++]=(byte)'\r';
  -                        outdata[o++]=(byte)'\n';
  -                        line=o;
  -                        col=0;
  -                        break;
  -
  -                    default:
  -                        // add tabs if two or more spaces are required
  -                        if (addtab>0 && o+1<line+col) {
  -                            // determine logical column
  -                            int diff=o-line;
  -
  -                            // add tabs until this column would be passed
  -                            // note: the start of line is adjusted to match
  -                            while ((diff|7)<col) {
  +                        case '\t':
  +                            if (addtab == 0) {
  +                                // treat like any other character
                                   outdata[o++]=(byte)'\t';
  -                                line-=7-(diff&7);
  -                                diff=o-line;
  +                                col++;
  +                            } else {
  +                                // advance column to next tab stop
  +                                col = (col|7)+1;
  +                            }
  +                            break;
  +
  +                        case '\r':
  +                            if (addcr == 0) {
  +                                // treat like any other character
  +                                outdata[o++]=(byte)'\r';
  +                                col++;
  +                            }
  +                            break;
  +
  +                        case '\n':
  +                            // start a new line (optional CR followed by LF)
  +                            if (addcr == +1) outdata[o++]=(byte)'\r';
  +                            outdata[o++]=(byte)'\n';
  +                            line=o;
  +                            col=0;
  +                            break;
  +
  +                        default:
  +                            // add tabs if two or more spaces are required
  +                            if (addtab>0 && o+1<line+col) {
  +                                // determine logical column
  +                                int diff=o-line;
  +
  +                                // add tabs until this column would be passed
  +                                // note: the start of line is adjusted to match
  +                                while ((diff|7)<col) {
  +                                    outdata[o++]=(byte)'\t';
  +                                    line-=7-(diff&7);
  +                                    diff=o-line;
  +                                };
                               };
  -                        };
   
  -                        // space out to desired column
  -                        while (o<line+col) outdata[o++]=(byte)' ';
  +                            // space out to desired column
  +                            while (o<line+col) outdata[o++]=(byte)' ';
   
  -                        // append desired character
  -                        outdata[o++]=indata[k];
  -                        col++;
  +                            // append desired character
  +                            outdata[o++]=indata[k];
  +                            col++;
  +                    }
                   }
  -            }
   
  -            // add or remove an eof character as required
  -            if (ctrlz == +1) {
  -                if (outdata[o-1]!=0x1A) outdata[o++]=0x1A;
  -            } else if (ctrlz == -1) {
  -                if (o>2 && outdata[o-1]==0x0A && outdata[o-2]==0x1A) o--;
  -                if (o>1 && outdata[o-1]==0x1A) o--;
  -            }
  +                // add or remove an eof character as required
  +                if (ctrlz == +1) {
  +                    if (outdata[o-1]!=0x1A) outdata[o++]=0x1A;
  +                } else if (ctrlz == -1) {
  +                    if (o>2 && outdata[o-1]==0x0A && outdata[o-2]==0x1A) o--;
  +                    if (o>1 && outdata[o-1]==0x1A) o--;
  +                }
   
  -            // output the data
  -            try {
  -                File destFile = srcFile;
  -                if (destDir != null) destFile = new File(destDir, files[i]);
  -                FileOutputStream outStream = new FileOutputStream(destFile);
  -                outStream.write(outdata,0,o);
  -                outStream.close();
  -            } catch (IOException e) {
  -                throw new BuildException(e);
  -            }
  +                // output the data
  +                try {
  +                    File destFile = srcFile;
  +                    if (destDir != null) destFile = new File(destDir, files[i]);
  +                    FileOutputStream outStream = new FileOutputStream(destFile);
  +                    outStream.write(outdata,0,o);
  +                    outStream.close();
  +                } catch (IOException e) {
  +                    throw new BuildException(e);
  +                }
   
  -        } /* end for */
  -} catch (Exception e) {e.printStackTrace(); throw new BuildException(e); }
  +            } /* end for */
  +        } catch (Exception e) {
  +            e.printStackTrace();
  +            throw new BuildException(e);
  +        }
       }
   }
  
  
  
  1.4       +3 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java
  
  Index: Java.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Java.java	2000/02/09 20:51:48	1.3
  +++ Java.java	2000/02/13 18:20:00	1.4
  @@ -62,7 +62,7 @@
    * This task acts as a loader for java applications but allows to use the same JVM 
    * for the called application thus resulting in much faster operation.
    *
  - * @author Stefano Mazzocchi <a href="mailto:stefano@pache.org">stefano@apache.org</a>
  + * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a>
    */
   public class Java extends Exec {
   
  @@ -87,7 +87,7 @@
               StringBuffer b = new StringBuffer();
               b.append("java ");
               if (classpath != null) {
  -                b.append("-cp ");
  +                b.append("-classpath ");
                   b.append(classpath);
                   b.append(" ");
               }
  @@ -114,7 +114,7 @@
        * Set the classpath to be used for this compilation.
        */
       public void setClasspath(String s) {
  -        this.classpath = Project.translatePath(s);
  +        this.classpath = project.translatePath(s);
       }
       
       /**
  
  
  
  1.5       +4 -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java
  
  Index: Javac.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Javac.java	2000/02/09 20:51:48	1.4
  +++ Javac.java	2000/02/13 18:20:00	1.5
  @@ -118,7 +118,7 @@
        * Set the classpath to be used for this compilation.
        */
       public void setClasspath(String classpath) {
  -        compileClasspath = Project.translatePath(classpath);
  +        compileClasspath = project.translatePath(classpath);
       }
   
       /**
  @@ -126,7 +126,7 @@
        * against.
        */
       public void setBootclasspath(String bootclasspath) {
  -        this.bootclasspath = Project.translatePath(bootclasspath);
  +        this.bootclasspath = project.translatePath(bootclasspath);
       }
   
       /**
  @@ -134,7 +134,7 @@
        * compilation.
        */
       public void setExtdirs(String extdirs) {
  -        this.extdirs = Project.translatePath(extdirs);
  +        this.extdirs = project.translatePath(extdirs);
       }
   
       /**
  @@ -228,7 +228,7 @@
                   String fromFile = (String)enum.nextElement();
                   String toFile = (String)filecopyList.get(fromFile);
                   try {
  -                    copyFile(fromFile, toFile);
  +                    project.copyFile(fromFile, toFile);
                   } catch (IOException ioe) {
                       String msg = "Failed to copy " + fromFile + " to " + toFile
                           + " due to " + ioe.getMessage();
  
  
  
  1.6       +2 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  
  Index: Javadoc.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Javadoc.java	2000/02/06 21:16:57	1.5
  +++ Javadoc.java	2000/02/13 18:20:00	1.6
  @@ -160,10 +160,10 @@
           old = Project.toBoolean(src);
       }
       public void setClasspath(String src) {
  -        classpath = Project.translatePath(src);
  +        classpath = project.translatePath(src);
       }
       public void setBootclasspath(String src) {
  -        bootclasspath = Project.translatePath(src);
  +        bootclasspath = project.translatePath(src);
       }
       public void setExtdirs(String src) {
           extdirs = src;
  
  
  
  1.2       +1 -0      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/KeySubst.java
  
  Index: KeySubst.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/KeySubst.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- KeySubst.java	2000/01/13 10:41:41	1.1
  +++ KeySubst.java	2000/02/13 18:20:00	1.2
  @@ -76,6 +76,7 @@
           Do the execution.
       */
       public void execute() throws BuildException {
  +        project.log("!! KeySubst is deprecated. Use Filter + CopyDir instead. !!");
           project.log("Performing Substitions");
           if ( source == null || dest == null ) {
               project.log("Source and destinations must not be null");
  
  
  
  1.3       +3 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java
  
  Index: Rmic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Rmic.java	2000/01/26 00:54:35	1.2
  +++ Rmic.java	2000/02/13 18:20:00	1.3
  @@ -103,7 +103,7 @@
        * Set the classpath to be used for this compilation.
        */
       public void setClasspath(String classpath) {
  -        compileClasspath = Project.translatePath(classpath);
  +        compileClasspath = project.translatePath(classpath);
       }
   
       public void execute() throws BuildException {
  @@ -144,7 +144,7 @@
               File oldStubFile = new File(baseFile, stubFileName);
               File newStubFile = new File(sourceBaseFile, stubFileName);
               try {
  -                copyFile(oldStubFile, newStubFile);
  +                project.copyFile(oldStubFile, newStubFile);
                   oldStubFile.delete();
               } catch (IOException ioe) {
                   String msg = "Failed to copy " + oldStubFile + " to " + 
  @@ -156,7 +156,7 @@
                   File oldSkelFile = new File(baseFile, skelFileName);
                   File newSkelFile = new File(sourceBaseFile, skelFileName);
                   try {
  -            	    copyFile(oldSkelFile, newSkelFile);
  +            	    project.copyFile(oldSkelFile, newSkelFile);
               	    oldSkelFile.delete();
                   } catch (IOException ioe) {
                       String msg = "Failed to copy " + oldSkelFile + " to " + 
  
  
  
  1.7       +2 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties
  
  Index: defaults.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- defaults.properties	2000/02/12 16:59:26	1.6
  +++ defaults.properties	2000/02/13 18:20:00	1.7
  @@ -13,7 +13,6 @@
   expand=org.apache.tools.ant.taskdefs.Expand
   echo=org.apache.tools.ant.taskdefs.Echo
   javadoc=org.apache.tools.ant.taskdefs.Javadoc
  -keysubst=org.apache.tools.ant.taskdefs.KeySubst
   zip=org.apache.tools.ant.taskdefs.Zip
   gzip=org.apache.tools.ant.taskdefs.GZip
   replace=org.apache.tools.ant.taskdefs.Replace
  @@ -25,7 +24,9 @@
   exec=org.apache.tools.ant.taskdefs.Exec
   tar=org.apache.tools.ant.taskdefs.Tar
   available=org.apache.tools.ant.taskdefs.Available
  +filter=org.apache.tools.ant.taskdefs.Filter
   fixcrlf=org.apache.tools.ant.taskdefs.FixCRLF
   
   # deprecated ant tasks (kept for back compatibility)
   javadoc2=org.apache.tools.ant.taskdefs.Javadoc
  +keysubst=org.apache.tools.ant.taskdefs.KeySubst