diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java
index e239d44be..77b2ed42e 100644
--- a/src/main/org/apache/tools/ant/DirectoryScanner.java
+++ b/src/main/org/apache/tools/ant/DirectoryScanner.java
@@ -58,6 +58,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Vector;
import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.ResourceFactory;
import org.apache.tools.ant.types.selectors.FileSelector;
import org.apache.tools.ant.types.selectors.SelectorScanner;
import org.apache.tools.ant.types.selectors.SelectorUtils;
@@ -151,7 +152,7 @@ import org.apache.tools.ant.util.FileUtils;
* @author Bruce Atherton
* @author Antoine Levy-Lambert
*/
-public class DirectoryScanner implements ResourceScanner, SelectorScanner {
+public class DirectoryScanner implements FileScanner, SelectorScanner, ResourceFactory {
/**
* Patterns which should be excluded by default.
@@ -810,27 +811,6 @@ public class DirectoryScanner implements ResourceScanner, SelectorScanner {
return files;
}
- /**
- * Returns the resources of the files which matched at least one
- * of the include patterns and none of the exclude patterns. The
- * names are relative to the base directory.
- *
- * @return resource information for the files which matched at
- * least one of the include patterns and none of the exclude
- * patterns.
- *
- * @since Ant 1.5.2
- */
- public Resource[] getIncludedFileResources() {
- String[] names = getIncludedFiles();
- int count = names.length;
- Resource[] resources = new Resource[count];
- for (int i = 0; i < count; i++) {
- resources[i] = getResource(names[i]);
- }
- return resources;
- }
-
/**
* Returns the names of the files which matched none of the include
* patterns. The names are relative to the base directory. This involves
@@ -898,26 +878,6 @@ public class DirectoryScanner implements ResourceScanner, SelectorScanner {
return directories;
}
- /**
- * Returns the resource object for the directories which matched
- * at least one of the include patterns and none of the exclude
- * patterns. The names are relative to the base directory.
- *
- * @return the names of the directories which matched at least one of the
- * include patterns and none of the exclude patterns.
- *
- * @since Ant 1.5.2
- */
- public Resource[] getIncludedDirectoryResources() {
- String[] names = getIncludedDirectories();
- int count = names.length;
- Resource[] resources = new Resource[count];
- for (int i = 0; i < count; i++) {
- resources[i] = getResource(names[i]);
- }
- return resources;
- }
-
/**
* Returns the names of the directories which matched none of the include
* patterns. The names are relative to the base directory. This involves
@@ -994,12 +954,7 @@ public class DirectoryScanner implements ResourceScanner, SelectorScanner {
* @since Ant 1.5.2
*/
public Resource getResource(String name) {
- File f = null;
- if (basedir != null) {
- f = new File(basedir, name);
- } else {
- f = new File(name);
- }
+ File f = fileUtils.resolveFile(basedir, name);
return new Resource(name, f.exists(), f.lastModified(),
f.isDirectory());
}
diff --git a/src/main/org/apache/tools/ant/ResourceScanner.java b/src/main/org/apache/tools/ant/ResourceScanner.java
deleted file mode 100644
index 380bd0109..000000000
--- a/src/main/org/apache/tools/ant/ResourceScanner.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2003 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * 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
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * 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 "Ant" and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * 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"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- */
-package org.apache.tools.ant;
-
-import org.apache.tools.ant.types.Resource;
-import org.apache.tools.ant.types.ResourceFactory;
-
-/**
- * Extends the FileScanner concept to {@link
- * org.apache.tools.ant.types.Resource Resources}.
- *
- * @since Ant 1.5.2
- */
-public interface ResourceScanner extends FileScanner, ResourceFactory {
-
- /**
- * Returns resources for the directories which matched at least
- * one of the include patterns and none of the exclude patterns.
- *
- * @return resources for the directories which matched at least
- * one of the include patterns and none of the exclude patterns.
- */
- Resource[] getIncludedDirectoryResources();
-
- /**
- * Returns resources for the files which matched at least one of
- * the include patterns and none of the exclude patterns.
- *
- * @return the names of the files which matched at least one of the
- * include patterns and none of the exclude patterns.
- */
- Resource[] getIncludedFileResources();
-
-}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java
index 99bd5b3c8..6d785048e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Jar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java
@@ -70,7 +70,6 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ResourceScanner;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Resource;
diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java
index f1daf2422..cef3e771f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Zip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java
@@ -73,7 +73,6 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.FileScanner;
import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ResourceScanner;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;
@@ -441,10 +440,15 @@ public class Zip extends MatchingTask {
PatternSet.NameEntry ne = oldFiles.createExclude();
ne.setName((String) addedFiles.elementAt(i));
}
- addResources(oldFiles,
- oldFiles.getDirectoryScanner(getProject())
- .getIncludedFileResources(),
- zOut);
+ DirectoryScanner ds =
+ oldFiles.getDirectoryScanner(getProject());
+ String[] f = ds.getIncludedFiles();
+ Resource[] r = new Resource[f.length];
+ for (int i = 0; i < f.length; i++) {
+ r[i] = ds.getResource(f[i]);
+ }
+
+ addResources(oldFiles, r, zOut);
}
finalizeZipOutputStream(zOut);
@@ -801,13 +805,20 @@ public class Zip extends MatchingTask {
protected Resource[][] grabResources(FileSet[] filesets) {
Resource[][] result = new Resource[filesets.length][];
for (int i = 0; i < filesets.length; i++) {
- ResourceScanner rs = filesets[i].getDirectoryScanner(getProject());
- Resource[] files = rs.getIncludedFileResources();
- Resource[] directories = rs.getIncludedDirectoryResources();
- result[i] = new Resource[files.length + directories.length];
- System.arraycopy(directories, 0, result[i], 0, directories.length);
- System.arraycopy(files, 0, result[i], directories.length,
- files.length);
+ DirectoryScanner rs =
+ filesets[i].getDirectoryScanner(getProject());
+ Vector resources = new Vector();
+ String[] directories = rs.getIncludedDirectories();
+ for (int j = 0; j < directories.length; j++) {
+ resources.add(rs.getResource(directories[j]));
+ }
+ String[] files = rs.getIncludedFiles();
+ for (int j = 0; j < files.length; j++) {
+ resources.add(rs.getResource(files[j]));
+ }
+
+ result[i] = new Resource[resources.size()];
+ resources.copyInto(result[i]);
}
return result;
}
diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java b/src/main/org/apache/tools/ant/types/ZipScanner.java
index 793f2bd59..46eaa5100 100644
--- a/src/main/org/apache/tools/ant/types/ZipScanner.java
+++ b/src/main/org/apache/tools/ant/types/ZipScanner.java
@@ -201,66 +201,6 @@ public class ZipScanner extends DirectoryScanner {
return isIncluded(vpath) && !isExcluded(vpath);
}
- /**
- * Returns the resources of the files which matched at least one of the
- * include patterns and none of the exclude patterns.
- * The names are relative to the base directory.
- *
- * @return resource information for the files which matched at
- * least one of the include patterns and none of the exclude
- * patterns.
- *
- * @since Ant 1.5.2
- */
- public Resource[] getIncludedFileResources() {
- if (srcFile != null) {
- Vector myvector = new Vector();
- // first check if the archive needs to be scanned again
- scanme();
- for (Enumeration e = myentries.elements(); e.hasMoreElements() ;) {
- Resource myresource= (Resource) e.nextElement();
- if (!myresource.isDirectory() && match(myresource.getName())) {
- myvector.addElement(myresource.clone());
- }
- }
- Resource[] resources = new Resource[myvector.size()];
- myvector.copyInto(resources);
- return resources;
- } else {
- return super.getIncludedFileResources();
- }
- }
-
- /**
- * Returns the resources of the files which matched at least one of the
- * include patterns and none of the exclude patterns.
- * The names are relative to the base directory.
- *
- * @return resource information for the files which matched at
- * least one of the include patterns and none of the exclude
- * patterns.
- *
- * @since Ant 1.5.2
- */
- public Resource[] getIncludedDirectoryResources() {
- if (srcFile != null) {
- Vector myvector = new Vector();
- // first check if the archive needs to be scanned again
- scanme();
- for (Enumeration e = myentries.elements(); e.hasMoreElements() ;) {
- Resource myresource= (Resource) e.nextElement();
- if (myresource.isDirectory() && match(myresource.getName())) {
- myvector.addElement(myresource.clone());
- }
- }
- Resource[] resources = new Resource[myvector.size()];
- myvector.copyInto(resources);
- return resources;
- } else {
- return super.getIncludedDirectoryResources();
- }
- }
-
/**
* @param name path name of the file sought in the archive
*
diff --git a/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java b/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java
index 95f05c801..91e5b982d 100644
--- a/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java
+++ b/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java
@@ -187,20 +187,6 @@ public class DirectoryScannerTest extends TestCase {
assertTrue("(1) zip package included", haveZipPackage);
assertTrue("(1) taskdefs package not included", !haveTaskdefsPackage);
- haveZipPackage = false;
- Resource[] includedResources = ds.getIncludedDirectoryResources();
- for (int i=0; i