ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: svn commit: r358627 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
Date Thu, 22 Dec 2005 23:28:33 GMT
:) sorry, fixed!

--- "Alexey N. Solofnenko" <a.solofnenko@mdl.com>
wrote:

> After the change <delete failonerror="no"> started
> to fail again if any 
> inner fileset directory does not exist:
> 
>     <delete failonerror="no" includeEmptyDirs="yes">
>       <fileset dir="already/deleted/dir"/>
>     </delete>
> 
> - Alexey.
> 
> mbenson@apache.org wrote:
> > Author: mbenson
> > Date: Thu Dec 22 12:57:47 2005
> > New Revision: 358627
> >
> > URL:
> http://svn.apache.org/viewcvs?rev=358627&view=rev
> > Log:
> > fixed fileset deletion slowdown.  Bugzilla 37297.
> >
> > Modified:
> >    
>
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
> >
> > Modified:
>
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
> > URL:
>
http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java?rev=358627&r1=358626&r2=358627&view=diff
> >
>
==============================================================================
> > ---
>
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
> (original)
> > +++
>
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
> Thu Dec 22 12:57:47 2005
> > @@ -18,20 +18,23 @@
> >  package org.apache.tools.ant.taskdefs;
> >  
> >  import java.io.File;
> > +import java.util.Arrays;
> >  import java.util.Vector;
> >  import java.util.Iterator;
> > +import java.util.ArrayList;
> > +import java.util.Comparator;
> >  
> >  import org.apache.tools.ant.Project;
> >  import org.apache.tools.ant.BuildException;
> >  import
> org.apache.tools.ant.taskdefs.condition.Os;
> > -import org.apache.tools.ant.types.Path;
> >  import org.apache.tools.ant.types.FileSet;
> >  import org.apache.tools.ant.types.PatternSet;
> >  import
> org.apache.tools.ant.types.ResourceCollection;
> >  import org.apache.tools.ant.types.resources.Sort;
> >  import
> org.apache.tools.ant.types.resources.Restrict;
> > -import
> org.apache.tools.ant.types.resources.BCFileSet;
> > +import
> org.apache.tools.ant.types.resources.Resources;
> >  import
> org.apache.tools.ant.types.resources.FileResource;
> > +import
>
org.apache.tools.ant.types.resources.FileResourceIterator;
> >  import
>
org.apache.tools.ant.types.resources.comparators.Reverse;
> >  import
>
org.apache.tools.ant.types.resources.comparators.FileSystem;
> >  import
>
org.apache.tools.ant.types.resources.comparators.ResourceComparator;
> > @@ -74,6 +77,29 @@
> >      private static final ResourceComparator
> REVERSE_FILESYSTEM = new Reverse(new FileSystem());
> >      private static final ResourceSelector EXISTS
> = new Exists();
> >  
> > +    private static class ReverseDirs implements
> ResourceCollection {
> > +        static final Comparator REVERSE = new
> Comparator() {
> > +            public int compare(Object foo, Object
> bar) {
> > +                return ((Comparable)
> foo).compareTo(bar) * -1;
> > +            }
> > +        };
> > +        File basedir;
> > +        String[] dirs;
> > +        ReverseDirs(File basedir, String[] dirs)
> {
> > +            this.basedir = basedir;
> > +            this.dirs = dirs;
> > +            Arrays.sort(this.dirs, REVERSE);
> > +            //ArrayList al = new
> ArrayList(Arrays.asList(dirs));
> > +            //Collections.reverse(al);
> > +            //this.dirs = (String[])
> (al.toArray(new String[dirs.length]));
> > +        }
> > +        public Iterator iterator() {
> > +            return new
> FileResourceIterator(basedir, dirs);
> > +        }
> > +        public boolean isFilesystemOnly() {
> return true; }
> > +        public int size() { return dirs.length; }
> > +    }
> > +
> >      protected File file = null;
> >      protected File dir = null;
> >      protected Vector filesets = new Vector();
> > @@ -85,7 +111,7 @@
> >      private boolean quiet = false;
> >      private boolean failonerror = true;
> >      private boolean deleteOnExit = false;
> > -    private Vector rcs = new Vector();
> > +    private Resources rcs = null;
> >  
> >      /**
> >       * Set the name of a single file to be
> removed.
> > @@ -177,6 +203,10 @@
> >       * @param rc the filesystem-only
> ResourceCollection.
> >       */
> >      public void add(ResourceCollection rc) {
> > +        if (rc == null) {
> > +            return;
> > +        }
> > +        rcs = (rcs == null) ? new Resources() :
> rcs;
> >          rcs.add(rc);
> >      }
> >  
> > @@ -467,7 +497,7 @@
> >                  + "Use a nested fileset element
> instead.");
> >          }
> >  
> > -        if (file == null && dir == null &&
> filesets.size() == 0 && rcs.size() == 0) {
> > +        if (file == null && dir == null &&
> filesets.size() == 0 && rcs == null) {
> >              throw new BuildException("At least
> one of the file or dir "
> >                                       +
> "attributes, or a nested resource collection, "
> >                                       + "must be
> set.");
> > @@ -489,14 +519,7 @@
> >                      log("Deleting: " +
> file.getAbsolutePath());
> >  
> >                      if (!delete(file)) {
> > -                        String message = "Unable
> to delete file "
> > -                            +
> file.getAbsolutePath();
> > -                        if (failonerror) {
> > -                            throw new
> BuildException(message);
> > -                        } else {
> > -                            log(message, quiet ?
> Project.MSG_VERBOSE
> > -                                               :
> Project.MSG_WARN);
> > -                        }
> > +                        handle("Unable to delete
> file " + file.getAbsolutePath());
> >                      }
> >                  }
> >              } else {
> > @@ -521,50 +544,80 @@
> >              }
> >              removeDir(dir);
> >          }
> > -        Path p = new Path(getProject());
> > -        p.addAll(rcs);
> > +        Resources resourcesToDelete = new
> Resources();
> > +       
> resourcesToDelete.setProject(getProject());
> > +        Resources filesetDirs = new Resources();
> > +        filesetDirs.setProject(getProject());
> > +
> >          for (int i = 0; i < filesets.size(); i++)
> {
> >              FileSet fs = (FileSet)
> filesets.get(i);
> > -            p.add(includeEmpty ? new
> BCFileSet(fs) : fs);
> > +            resourcesToDelete.add(fs);
> > +            if (includeEmpty) {
> > +              filesetDirs.add(new
> ReverseDirs(fs.getDir(),
> > +                 
> fs.getDirectoryScanner().getIncludedDirectories()));
> > +            }
> >          }
> 
=== message truncated ===



		
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message