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/14 13:19:28 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Copydir.java Copyfile.java Javac.java Rmic.java

stefano     00/02/14 04:19:27

  Modified:    src/main/org/apache/tools/ant Project.java
               src/main/org/apache/tools/ant/taskdefs Copydir.java
                        Copyfile.java Javac.java Rmic.java
  Log:
  improved filtering granularity... now all tasks that use copyfile can turn filtering on and off on a task granularity level, useful to avoid binary corruption by filtering
  
  Revision  Changes    Path
  1.9       +24 -6     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Project.java	2000/02/13 18:19:59	1.8
  +++ Project.java	2000/02/14 12:19:26	1.9
  @@ -102,7 +102,6 @@
       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) {
  @@ -223,7 +222,6 @@
           log("Setting token to filter: " + token + " -> "
               + value, MSG_VERBOSE);
           this.filters.put(token, value);
  -        this.filtering = true;
       }
   
       public Hashtable getFilters() {
  @@ -505,15 +503,35 @@
       }
   
       /**
  +     * Convienence method to copy a file from a source to a destination.
  +     * No filtering is performed.
  +     *
  +     * @throws IOException
  +     */
  +    public void copyFile(String sourceFile, String destFile) throws IOException {
  +        copyFile(new File(sourceFile), new File(destFile), false);
  +    }
  +
  +    /**
        * Convienence method to copy a file from a source to a destination
  -     * using token filtering.
  +     * specifying if token filtering must be used.
        *
        * @throws IOException
        */
  -    public void copyFile(String sourceFile, String destFile)
  +    public void copyFile(String sourceFile, String destFile, boolean filtering)
           throws IOException
       {
  -        copyFile(new File(sourceFile), new File(destFile));
  +        copyFile(new File(sourceFile), new File(destFile), filtering);
  +    }
  +
  +    /**
  +     * Convienence method to copy a file from a source to a destination.
  +     * No filtering is performed.
  +     *
  +     * @throws IOException
  +     */
  +    public void copyFile(File sourceFile, File destFile) throws IOException {
  +        copyFile(sourceFile, destFile, false);
       }
   
       /**
  @@ -522,7 +540,7 @@
        *
        * @throws IOException
        */
  -    public void copyFile(File sourceFile, File destFile)
  +    public void copyFile(File sourceFile, File destFile, boolean filtering)
           throws IOException
       {
   
  
  
  
  1.6       +8 -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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Copydir.java	2000/02/13 18:20:00	1.5
  +++ Copydir.java	2000/02/14 12:19:27	1.6
  @@ -69,6 +69,7 @@
   
       private File srcDir;
       private File destDir;
  +    private boolean filtering = false;
       private Hashtable filecopyList = new Hashtable();
   
       public void setSrc(String src) {
  @@ -79,15 +80,19 @@
           destDir = project.resolveFile(dest);
       }
   
  +    public void setFiltering(String filter) {
  +        filtering = Project.toBoolean(filter);
  +    }
  +
       public void execute() throws BuildException {
           if (srcDir == null) {
               throw new BuildException("srcdir attribute must be set!");
           }
  -        
  +
           if (!srcDir.exists()) {
               throw new BuildException("srcdir does not exist!");
           }
  -        
  +
           DirectoryScanner ds = super.getDirectoryScanner(srcDir);
   
           String[] files = ds.getIncludedFiles();
  @@ -100,7 +105,7 @@
                   String fromFile = (String) enum.nextElement();
                   String toFile = (String) filecopyList.get(fromFile);
                   try {
  -                    project.copyFile(fromFile, toFile);
  +                    project.copyFile(fromFile, toFile, filtering);
                   } catch (IOException ioe) {
                       String msg = "Failed to copy " + fromFile + " to " + toFile
                           + " due to " + ioe.getMessage();
  
  
  
  1.3       +8 -3      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Copyfile.java	2000/02/13 18:20:00	1.2
  +++ Copyfile.java	2000/02/14 12:19:27	1.3
  @@ -67,8 +67,9 @@
   
   public class Copyfile extends Task {
   
  -    public File srcFile;
  -    public File destFile;
  +    private File srcFile;
  +    private File destFile;
  +    private boolean filtering = false;
   
       public void setSrc(String src) {
           srcFile = project.resolveFile(src);
  @@ -78,10 +79,14 @@
           destFile = project.resolveFile(dest);
       }
   
  +    public void setFiltering(String filter) {
  +        filtering = Project.toBoolean(filter);
  +    }
  +
       public void execute() throws BuildException {
           if (srcFile.lastModified() > destFile.lastModified()) {
               try {
  -                project.copyFile(srcFile, destFile);
  +                project.copyFile(srcFile, destFile, filtering);
               } catch (IOException ioe) {
                   String msg = "Error copying file: " + srcFile.getAbsolutePath()
                       + " due to " + ioe.getMessage();
  
  
  
  1.6       +11 -3     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Javac.java	2000/02/13 18:20:00	1.5
  +++ Javac.java	2000/02/14 12:19:27	1.6
  @@ -92,6 +92,7 @@
       private boolean debug = false;
       private boolean optimize = false;
       private boolean deprecation = false;
  +    private boolean filtering = false;
       private String target;
       private String bootclasspath;
       private String extdirs;
  @@ -167,6 +168,13 @@
       }
   
       /**
  +     * Set the filtering flag.
  +     */
  +    public void setFiltering(String filter) {
  +        filtering = Project.toBoolean(filter);
  +    }
  +
  +    /**
        * Executes the task.
        */
       public void execute() throws BuildException {
  @@ -225,10 +233,10 @@
                           " support files to " + 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 {
  -                    project.copyFile(fromFile, toFile);
  +                    project.copyFile(fromFile, toFile, filtering);
                   } catch (IOException ioe) {
                       String msg = "Failed to copy " + fromFile + " to " + toFile
                           + " due to " + ioe.getMessage();
  
  
  
  1.4       +36 -31    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Rmic.java	2000/02/13 18:20:00	1.3
  +++ Rmic.java	2000/02/14 12:19:27	1.4
  @@ -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"
  @@ -50,7 +50,7 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - */ 
  + */
   
   package org.apache.tools.ant.taskdefs;
   
  @@ -82,21 +82,26 @@
       private String sourceBase;
       private String stubVersion;
       private String compileClasspath;
  +    private boolean filtering = false;
   
       public void setBase(String base) {
  -	this.base = base;
  +        this.base = base;
       }
   
       public void setClass(String classname) {
  -	this.classname = classname;
  +        this.classname = classname;
       }
   
       public void setSourceBase(String sourceBase) {
  -    	this.sourceBase = sourceBase;
  +        this.sourceBase = sourceBase;
       }
   
       public void setStubVersion(String stubVersion) {
  -    	this.stubVersion = stubVersion;
  +        this.stubVersion = stubVersion;
  +    }
  +
  +    public void setFiltering(String filter) {
  +        filtering = Project.toBoolean(filter);
       }
   
       /**
  @@ -107,16 +112,16 @@
       }
   
       public void execute() throws BuildException {
  -	File baseFile = project.resolveFile(base);
  +        File baseFile = project.resolveFile(base);
           File sourceBaseFile = null;
           if (null != sourceBase)
               sourceBaseFile = project.resolveFile(sourceBase);
           String classpath = getCompileClasspath(baseFile);
  -	// XXX
  -	// need to provide an input stream that we read in from!
  +        // XXX
  +        // need to provide an input stream that we read in from!
   
  -	sun.rmi.rmic.Main compiler = new sun.rmi.rmic.Main(System.out, "rmic");
  -  	    int argCount = 5;
  +        sun.rmi.rmic.Main compiler = new sun.rmi.rmic.Main(System.out, "rmic");
  +            int argCount = 5;
           int i = 0;
           if (null != stubVersion) argCount++;
           if (null != sourceBase) argCount++;
  @@ -140,14 +145,14 @@
   
           // Move the generated source file to the base directory
           if (null != sourceBase) {
  -        	String stubFileName = classname.replace('.', '/') + "_Stub.java";
  +                String stubFileName = classname.replace('.', '/') + "_Stub.java";
               File oldStubFile = new File(baseFile, stubFileName);
               File newStubFile = new File(sourceBaseFile, stubFileName);
               try {
  -                project.copyFile(oldStubFile, newStubFile);
  +                project.copyFile(oldStubFile, newStubFile, filtering);
                   oldStubFile.delete();
               } catch (IOException ioe) {
  -                String msg = "Failed to copy " + oldStubFile + " to " + 
  +                String msg = "Failed to copy " + oldStubFile + " to " +
                                newStubFile + " due to " + ioe.getMessage();
                   throw new BuildException(msg);
               }
  @@ -156,10 +161,10 @@
                   File oldSkelFile = new File(baseFile, skelFileName);
                   File newSkelFile = new File(sourceBaseFile, skelFileName);
                   try {
  -            	    project.copyFile(oldSkelFile, newSkelFile);
  -            	    oldSkelFile.delete();
  +                    project.copyFile(oldSkelFile, newSkelFile, filtering);
  +                    oldSkelFile.delete();
                   } catch (IOException ioe) {
  -                    String msg = "Failed to copy " + oldSkelFile + " to " + 
  +                    String msg = "Failed to copy " + oldSkelFile + " to " +
                                     newSkelFile + " due to " + ioe.getMessage();
                       throw new BuildException(msg);
                   }
  @@ -175,19 +180,19 @@
       // we need a way to not use the current classpath.
   
       private String getCompileClasspath(File baseFile) {
  -	StringBuffer classpath = new StringBuffer();
  +        StringBuffer classpath = new StringBuffer();
   
  -	// add dest dir to classpath so that previously compiled and
  -	// untouched classes are on classpath
  -	classpath.append(baseFile.getAbsolutePath());
  +        // add dest dir to classpath so that previously compiled and
  +        // untouched classes are on classpath
  +        classpath.append(baseFile.getAbsolutePath());
   
  -	// add our classpath to the mix
  +        // add our classpath to the mix
   
  -	if (compileClasspath != null) {
  +        if (compileClasspath != null) {
               addExistingToClasspath(classpath,compileClasspath);
  -	}
  +        }
   
  -	// add the system classpath
  +        // add the system classpath
   
           addExistingToClasspath(classpath,System.getProperty("java.class.path"));
           // in jdk 1.2, the system classes are not on the visible classpath.
  @@ -195,10 +200,10 @@
           if (Project.getJavaVersion().startsWith("1.2")) {
               String bootcp = System.getProperty("sun.boot.class.path");
               if (bootcp != null) {
  -            	addExistingToClasspath(classpath, bootcp);
  +                addExistingToClasspath(classpath, bootcp);
               }
           }
  -	return classpath.toString();
  +        return classpath.toString();
       }
   
        /**