You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by jo...@hyperreal.org on 1999/11/29 01:22:30 UTC

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

jons        99/11/28 16:22:30

  Modified:    ant/src/main/org/apache/tools/ant/taskdefs Copydir.java
  Log:
  allow ignoring of files and directories
  
  Revision  Changes    Path
  1.5       +49 -20    jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs/Copydir.java
  
  Index: Copydir.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tools/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	1999/11/23 08:27:28	1.4
  +++ Copydir.java	1999/11/29 00:22:30	1.5
  @@ -71,6 +71,7 @@
       public File destDir;
   
       private Hashtable filecopyList = new Hashtable();
  +    private Vector ignoreList = new Vector();
   
       public void setSrc(String src) {
   	srcDir = project.resolveFile(src);
  @@ -100,25 +101,53 @@
   	}
       }
   
  +    /**
  +        List of filenames and directory names to not 
  +        include in the final .jar file. They should be either 
  +        , or " " (space) separated.
  +        <p>
  +        For example:
  +        <p>
  +        ignore="package.html, foo.class"
  +        <p>
  +        The ignored files will be logged.
  +        
  +        @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
  +    */
  +    public void setIgnore(String ignoreString) {
  +        ignoreString = ignoreString;
  +        if (ignoreString != null && ignoreString.length() > 0) {
  +            StringTokenizer tok =
  +            new StringTokenizer(ignoreString, ", ", false);
  +            while (tok.hasMoreTokens()) {
  +                ignoreList.addElement ( tok.nextToken().trim() );
  +            }
  +        }
  +    }
  +
       private void scanDir(File from, File to) {
  -	String[] list = from.list(new DesirableFilter());
  -	if (list == null) {
  -	    project.log("Source directory " + srcDir.getAbsolutePath()
  -			+ " does not exist.", "copydir", Project.MSG_WARN);
  -	    return;
  -	}
  -	for (int i = 0; i < list.length; i++) {
  -	    String filename = list[i];
  -	    File srcFile = new File(from, filename);
  -	    File destFile = new File(to, filename);
  -	    if (srcFile.isDirectory()) {
  -		scanDir(srcFile, destFile);
  -	    } else {
  -		if (srcFile.lastModified() > destFile.lastModified()) {
  -		    filecopyList.put(srcFile.getAbsolutePath(),
  -				     destFile.getAbsolutePath());
  -		}
  -	    }
  -	}
  +        String[] list = from.list(new DesirableFilter());
  +        if (list == null) {
  +            project.log("Source directory " + srcDir.getAbsolutePath()
  +                + " does not exist.", "copydir", Project.MSG_WARN);
  +            return;
  +        }
  +        for (int i = 0; i < list.length; i++) {
  +            String filename = list[i];
  +            File srcFile = new File(from, filename);
  +            File destFile = new File(to, filename);
  +            if ( ! ignoreList.contains(filename) ) {            
  +                if (srcFile.isDirectory()) {
  +                    scanDir(srcFile, destFile);
  +                } else {
  +                    if (srcFile.lastModified() > destFile.lastModified()) {
  +                        filecopyList.put(srcFile.getAbsolutePath(),
  +                                 destFile.getAbsolutePath());
  +                    }
  +                }
  +            } else {
  +                project.log("Copydir Ignored: " + filename, Project.MSG_WARN);
  +            }
  +        }
       }
  -}
  +}
  \ No newline at end of file
  
  
  

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

Posted by "Craig R. McClanahan" <cm...@mytownnet.com>.
jons@hyperreal.org wrote:

> jons        99/11/28 16:22:30
>
>   Modified:    ant/src/main/org/apache/tools/ant/taskdefs Copydir.java
>   Log:
>   allow ignoring of files and directories
>

When posting changes to Ant, could you guys also remember to check in a new "ant.jar" file at
the top level directory of jakarta-tools?  The new features cannot be used unless I remember to
rebuild ant.jar myself -- and that fails right now on my platform (see subsequent message on
tomcat-dev).

Craig McClanahan