ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1079735 - in /ant/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/ant/IvyCacheFileset.java test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java
Date Wed, 09 Mar 2011 10:42:46 GMT
Author: hibou
Date: Wed Mar  9 10:42:45 2011
New Revision: 1079735

URL: http://svn.apache.org/viewvc?rev=1079735&view=rev
Log:
IVY-1272:
 - use an java empty iterator rather than having an exclude-all filset which might still read
the filesystem

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1079735&r1=1079734&r2=1079735&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Mar  9 10:42:45 2011
@@ -138,6 +138,7 @@ for detailed view of each issue, please 
 - FIX: UseCacheOnly is influenced by the TTL on cached metadata (IVY-1243)
 - FIX: ConcurrentModificationException on ivy settings loading (IVY-1250)
 - FIX: Module inheritance sometimes fails to locate parent descriptor in deliver process
(IVY-1248) (thanks to Jean-Louis Boudart)
+- FIX: <cachefileset> on an empty configuration produces a very slow-to-evaluate fileset
(IVY-1272)
 
    2.2.0
 =====================================

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java?rev=1079735&r1=1079734&r2=1079735&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java Wed Mar  9 10:42:45
2011
@@ -21,9 +21,12 @@ import java.io.File;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.NoSuchElementException;
 
 import org.apache.ivy.core.report.ArtifactDownloadReport;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.PatternSet.NameEntry;
 
@@ -57,10 +60,6 @@ public class IvyCacheFileset extends Ivy
             throw new BuildException("setid is required in ivy cachefileset");
         }
         try {
-            FileSet fileset = new FileSet();
-            fileset.setProject(getProject());
-            getProject().addReference(setid, fileset);
-
             List paths = getArtifactReports();
             File base = null;
             for (Iterator iter = paths.iterator(); iter.hasNext();) {
@@ -69,11 +68,12 @@ public class IvyCacheFileset extends Ivy
                     base = getBaseDir(base, a.getLocalFile());
                 }
             }
+
+            FileSet fileset;
             if (base == null) {
-                fileset.setDir(new File("."));
-                NameEntry ne = fileset.createExclude();
-                ne.setName("**/*");
+                fileset = new EmptyFileSet();
             } else {
+                fileset = new FileSet();
                 fileset.setDir(base);
                 for (Iterator iter = paths.iterator(); iter.hasNext();) {
                     ArtifactDownloadReport a = (ArtifactDownloadReport) iter.next();
@@ -83,6 +83,9 @@ public class IvyCacheFileset extends Ivy
                     }
                 }
             }
+
+            fileset.setProject(getProject());
+            getProject().addReference(setid, fileset);
         } catch (Exception ex) {
             throw new BuildException("impossible to build ivy cache fileset: " + ex, ex);
         }
@@ -152,4 +155,48 @@ public class IvyCacheFileset extends Ivy
         return r;
     }
 
+    private static class EmptyFileSet extends FileSet {
+
+        private DirectoryScanner ds = new EmptyDirectoryScanner();
+
+        public Iterator iterator() {
+            return new EmptyIterator();
+        }
+        
+        public Object clone() {
+            return new EmptyFileSet();
+        }
+
+        public int size() {
+            return 0;
+        }
+
+        public DirectoryScanner getDirectoryScanner(Project project) {
+            return ds;
+        }
+    }
+
+    private static class EmptyIterator implements Iterator {
+
+        public boolean hasNext() {
+            return false;
+        }
+
+        public Object next() {
+            throw new NoSuchElementException("EmptyFileSet Iterator");
+        }
+
+        public void remove() {
+            throw new IllegalStateException("EmptyFileSet Iterator");
+        }
+
+    }
+
+    private static class EmptyDirectoryScanner extends DirectoryScanner {
+
+        public String[] getIncludedFiles() {
+            return new String[0];
+        }
+
+    }
 }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java?rev=1079735&r1=1079734&r2=1079735&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java Wed Mar  9 10:42:45
2011
@@ -98,6 +98,7 @@ public class IvyCacheFilesetTest extends
         assertTrue(ref instanceof FileSet);
         FileSet fs = (FileSet) ref;
         DirectoryScanner directoryScanner = fs.getDirectoryScanner(project);
+        directoryScanner.scan();
         assertEquals(0, directoryScanner.getIncludedFiles().length);
     }
 



Mime
View raw message