ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r671690 - in /ant/core/trunk/src/main/org/apache/tools/ant: taskdefs/ types/ types/resources/
Date Wed, 25 Jun 2008 23:39:01 GMT
Author: mbenson
Date: Wed Jun 25 16:39:01 2008
New Revision: 671690

URL: http://svn.apache.org/viewvc?rev=671690&view=rev
Log:
add Project to FileResourceIterator

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java?rev=671690&r1=671689&r2=671690&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 Wed Jun 25 16:39:01
2008
@@ -83,15 +83,17 @@
                 return ((Comparable) foo).compareTo(bar) * -1;
             }
         };
+        private Project project;
         private File basedir;
         private String[] dirs;
-        ReverseDirs(File basedir, String[] dirs) {
+        ReverseDirs(Project project, File basedir, String[] dirs) {
+            this.project = project;
             this.basedir = basedir;
             this.dirs = dirs;
             Arrays.sort(this.dirs, REVERSE);
         }
         public Iterator iterator() {
-            return new FileResourceIterator(basedir, dirs);
+            return new FileResourceIterator(project, basedir, dirs);
         }
         public boolean isFilesystemOnly() { return true; }
         public int size() { return dirs.length; }
@@ -571,7 +573,7 @@
             } else {
                 resourcesToDelete.add(fs);
                 if (includeEmpty) {
-                    filesetDirs.add(new ReverseDirs(fsDir, fs
+                    filesetDirs.add(new ReverseDirs(getProject(), fsDir, fs
                             .getDirectoryScanner().getIncludedDirectories()));
                 }
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java?rev=671690&r1=671689&r2=671690&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java Wed Jun 25 16:39:01
2008
@@ -270,7 +270,7 @@
             return super.iterator();
         }
         ArchiveScanner as = (ArchiveScanner) getDirectoryScanner(getProject());
-        return as.getResourceFiles();
+        return as.getResourceFiles(getProject());
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java?rev=671690&r1=671689&r2=671690&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java Wed Jun 25 16:39:01
2008
@@ -25,6 +25,7 @@
 import java.util.Iterator;
 
 import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.resources.FileResource;
 import org.apache.tools.ant.types.resources.FileResourceIterator;
 
@@ -189,12 +190,13 @@
 
     /**
      * Get the set of Resources that represent files.
+     * @param project since Ant 1.8
      * @return an Iterator of Resources.
      * @since Ant 1.7
      */
-    /* package-private for now */ Iterator getResourceFiles() {
+    /* package-private for now */ Iterator getResourceFiles(Project project) {
         if (src == null) {
-            return new FileResourceIterator(getBasedir(), getIncludedFiles());
+            return new FileResourceIterator(project, getBasedir(), getIncludedFiles());
         }
         scanme();
         return matchFileEntries.values().iterator();
@@ -202,12 +204,13 @@
 
     /**
      * Get the set of Resources that represent directories.
+     * @param project since Ant 1.8
      * @return an Iterator of Resources.
      * @since Ant 1.7
      */
-    /* package-private for now */  Iterator getResourceDirectories() {
+    /* package-private for now */  Iterator getResourceDirectories(Project project) {
         if (src == null) {
-            return new FileResourceIterator(getBasedir(), getIncludedDirectories());
+            return new FileResourceIterator(project, getBasedir(), getIncludedDirectories());
         }
         scanme();
         return matchDirEntries.values().iterator();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java?rev=671690&r1=671689&r2=671690&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java Wed Jun 25 16:39:01 2008
@@ -67,7 +67,7 @@
         if (isReference()) {
             return ((DirSet) getRef(getProject())).iterator();
         }
-        return new FileResourceIterator(getDir(getProject()),
+        return new FileResourceIterator(getProject(), getDir(getProject()),
             getDirectoryScanner(getProject()).getIncludedDirectories());
     }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java?rev=671690&r1=671689&r2=671690&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java Wed Jun 25 16:39:01 2008
@@ -192,7 +192,7 @@
         if (isReference()) {
             return ((FileList) getRef(getProject())).iterator();
         }
-        return new FileResourceIterator(dir,
+        return new FileResourceIterator(getProject(), dir,
             (String[]) (filenames.toArray(new String[filenames.size()])));
     }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java?rev=671690&r1=671689&r2=671690&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java Wed Jun 25 16:39:01 2008
@@ -66,7 +66,7 @@
         if (isReference()) {
             return ((FileSet) getRef(getProject())).iterator();
         }
-        return new FileResourceIterator(getDir(getProject()),
+        return new FileResourceIterator(getProject(), getDir(getProject()),
             getDirectoryScanner(getProject()).getIncludedFiles());
     }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java?rev=671690&r1=671689&r2=671690&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java Wed Jun 25 16:39:01 2008
@@ -121,7 +121,7 @@
          * @return an iterator.
          */
         public Iterator iterator() {
-            return new FileResourceIterator(null, parts);
+            return new FileResourceIterator(getProject(), null, parts);
         }
 
         /**
@@ -688,7 +688,7 @@
         }
         dieOnCircularReference();
         if (getPreserveBC()) {
-            return new FileResourceIterator(null, list());
+            return new FileResourceIterator(getProject(), null, list());
         }
         return union == null ? EMPTY_ITERATOR
             : assertFilesystemOnly(union).iterator();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java?rev=671690&r1=671689&r2=671690&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java Wed Jun 25
16:39:01 2008
@@ -50,7 +50,7 @@
         if (isReference()) {
             return ((FileSet) getRef(getProject())).iterator();
         }
-        FileResourceIterator result = new FileResourceIterator(getDir());
+        FileResourceIterator result = new FileResourceIterator(getProject(), getDir());
         result.addFiles(getDirectoryScanner().getIncludedFiles());
         result.addFiles(getDirectoryScanner().getIncludedDirectories());
         return result;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java?rev=671690&r1=671689&r2=671690&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java
Wed Jun 25 16:39:01 2008
@@ -21,39 +21,78 @@
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
+import org.apache.tools.ant.Project;
+
 /**
  * Iterator of FileResources from filenames.
  * @since Ant 1.7
  */
 public class FileResourceIterator implements Iterator {
+    private Project project;
     private File basedir;
     private String[] files;
     private int pos = 0;
 
     /**
      * Construct a new FileResourceIterator.
+     * @deprecated in favor of {@link FileResourceIterator#FileResourceIterator(Project)}
      */
     public FileResourceIterator() {
     }
 
     /**
+     * Create a new FileResourceIterator.
+     * @param project associated Project instance
+     * @since Ant 1.8
+     */
+    public FileResourceIterator(Project project) {
+        this.project = project;
+    }
+
+    /**
      * Construct a new FileResourceIterator relative to the specified
      * base directory.
-     * @param f the base directory of this instance.
+     * @param basedir the base directory of this instance.
+     * @deprecated in favor of {@link FileResourceIterator#FileResourceIterator(Project,
File)}
      */
-    public FileResourceIterator(File f) {
-        basedir = f;
+    public FileResourceIterator(File basedir) {
+        this(null, basedir);
+    }
+
+    /**
+     * Construct a new FileResourceIterator relative to the specified
+     * base directory.
+     * @param project associated Project instance
+     * @param basedir the base directory of this instance.
+     * @since Ant 1.8
+     */
+    public FileResourceIterator(Project project, File basedir) {
+        this(project);
+        this.basedir = basedir;
     }
 
     /**
      * Construct a new FileResourceIterator over the specified filenames,
      * relative to the specified base directory.
-     * @param f the base directory of this instance.
-     * @param s the String[] of filenames.
+     * @param basedir the base directory of this instance.
+     * @param filenames the String[] of filenames.
+     * @deprecated in favor of {@link FileResourceIterator#FileResourceIterator(Project,
File, String[])}
      */
-    public FileResourceIterator(File f, String[] s) {
-        this(f);
-        addFiles(s);
+    public FileResourceIterator(File basedir, String[] filenames) {
+        this(null, basedir, filenames);
+    }
+
+    /**
+     * Construct a new FileResourceIterator over the specified filenames,
+     * relative to the specified base directory.
+     * @param project associated Project instance
+     * @param basedir the base directory of this instance.
+     * @param filenames the String[] of filenames.
+     * @since Ant 1.8
+     */
+    public FileResourceIterator(Project project, File basedir, String[] filenames) {
+        this(project, basedir);
+        addFiles(filenames);
     }
 
     /**
@@ -101,7 +140,9 @@
         if (!hasNext()) {
             throw new NoSuchElementException();
         }
-        return new FileResource(basedir, files[pos++]);
+        FileResource result = new FileResource(basedir, files[pos++]);
+        result.setProject(project);
+        return result;
     }
 
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java?rev=671690&r1=671689&r2=671690&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java Wed Jun 25 16:39:01
2008
@@ -321,7 +321,7 @@
         if (fct + dct == 0) {
             return EMPTY_ITERATOR;
         }
-        FileResourceIterator result = new FileResourceIterator();
+        FileResourceIterator result = new FileResourceIterator(getProject());
         if (fct > 0) {
             result.addFiles(ds.getIncludedFiles());
         }



Mime
View raw message