On 20 Jan 2002, Jose Alberto Fernandez <[EMAIL PROTECTED]> wrote:
> Why not improve the way <fileset/>s are defined, allowing use of mappers.

I made a quick and dirty patch for adding the <mappedfileset> element
and modifying the <delete> task to handle it, as you suggested.

Things to note.
1) The element's name is 'mappedfileest', not 'mapped-fileset'.
   This is because I don't know whether it is possible to have hyphens
   in data type names.

2) attributes of <mappedfileset>:

   Attribute      Description                                      Required
   --------------+------------------------------------------------+---------
   todir          The directory to map to.                         Yes
   skipSelf       Skip files which are mapped to themselves.       No
                  Defaults to "true"
   skipUptodate   Skip destination files which are uptodate        No
                  on comparison to source files.
                  Defaults to "false".

3) I think more improvements are needed, but I don't have a good idea now.
   Here is the situation:

   I added two classes: MappedFileSet and MappedDirectoryScanner.
   I made MappedFileSet a subclass of FileSet so that you could use
   MappedFilesets whereever FileSets can be used, but it is not possible
   with this patch unless a addMappedFileSets() method is added to each
   task which wants to handle MappedFileSets. Can somebody show me a
   better way?

   One more thing. MappedFileSet and MappedDirectoryScanner inherits
   many attributes but does not support most of those, so I made
   accessor methods throw BuildExceptions.  Is this acceptable?
   If not, is there a good solution?

I'd appreciate any ideas on this issue.
Thanks in advance.

Hiroaki Nakamura )[EMAIL PROTECTED])


diff -r -u -N 
jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/MappedDirectoryScanner.java
jakarta-ant-1.4.1/src/main/org/apache/tools/ant/MappedDirectoryScanner.java
--- 
jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/MappedDirectoryScanner.java
 Thu Jan  1 09:00:00 1970
+++ jakarta-ant-1.4.1/src/main/org/apache/tools/ant/MappedDirectoryScanner.java 
Sat Jan 26 03:08:18 2002
@@ -0,0 +1,479 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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 "The Jakarta Project", "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 [EMAIL PROTECTED]
+ *
+ * 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
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.tools.ant;
+
+import java.io.File;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Mapper;
+import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.FlatFileNameMapper;
+import org.apache.tools.ant.util.IdentityMapper;
+import org.apache.tools.ant.util.SourceFileScanner;
+
+/**
+ * Class for returning files in mapped file sets as a scan result.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Hiroaki Nakamura</a>
+ */
+public class MappedDirectoryScanner extends DirectoryScanner {
+    protected Project project = null;
+    protected File destDir = null; // the destination directory
+    protected Vector filesets = new Vector();
+    protected Mapper mapperElement = null;
+    protected boolean flatten = false;
+    protected boolean includeEmpty = true;
+    protected boolean skipSelf = true;
+    protected boolean skipUptodate = false;
+
+    protected Hashtable destFiles = new Hashtable();
+    protected Hashtable destDirs = new Hashtable();
+
+    /**
+     * Constructor.
+     */
+    public MappedDirectoryScanner() {
+    }
+
+    /**
+     * Sets the project.
+     */
+    public void setProject(Project project) {
+        this.project = project;
+    }
+
+    /**
+     * Sets the destination directory.
+     */
+    public void setTodir(File destDir) {
+        this.destDir = destDir;
+    }
+
+    /**
+     * Adds a set of files (nested fileset attribute).
+     */
+    public void setFilesets(Vector filesets) {
+        this.filesets = filesets;
+    }
+
+    /**
+     * Defines the FileNameMapper to use (nested mapper element).
+     */
+    public void setMapper(Mapper mapperElement) {
+        this.mapperElement = mapperElement;
+    }
+
+    /**
+     * Used to copy empty directories.
+     */
+    public void setIncludeEmptyDirs(boolean includeEmpty) {
+        this.includeEmpty = includeEmpty;
+    }
+
+    /**
+     * Skip destination files which are mapped from themselves.
+     */
+    public void setSkipself(boolean skipSelf) {
+        this.skipSelf = skipSelf;
+    }
+
+    /**
+     * Skip destination files which are up-to-date.
+     */
+    public void setSkipUptodate(boolean skipUptodate) {
+        this.skipUptodate = skipUptodate;
+    }
+
+    /**
+     * Does the path match the start of this pattern up to the first "**".
+     *
+     * <p>This is not a general purpose test and should only be used if you
+     * can live with false positives.</p>
+     *
+     * <p><code>pattern=**\\a</code> and <code>str=b</code> will yield true.
+     *
+     * @param pattern the (non-null) pattern to match against
+     * @param str     the (non-null) string (path) to match
+     */
+    protected static boolean matchPatternStart(String pattern, String str) {
+        throw unsupportedOperation("matchPatternStart");
+    }
+
+    /**
+     * Does the path match the start of this pattern up to the first "**".
+     *
+     * <p>This is not a general purpose test and should only be used if you
+     * can live with false positives.</p>
+     *
+     * <p><code>pattern=**\\a</code> and <code>str=b</code> will yield true.
+     *
+     * @param pattern             the (non-null) pattern to match against
+     * @param str                 the (non-null) string (path) to match
+     * @param isCaseSensitive     must matches be case sensitive?
+     */
+    protected static boolean matchPatternStart(
+        String pattern,
+        String str,
+        boolean isCaseSensitive) {
+        throw unsupportedOperation("matchPatternStart");
+    }
+
+    /**
+     * Matches a path against a pattern.
+     *
+     * @param pattern the (non-null) pattern to match against
+     * @param str     the (non-null) string (path) to match
+     *
+     * @return <code>true</code> when the pattern matches against the string.
+     *         <code>false</code> otherwise.
+     */
+    protected static boolean matchPath(String pattern, String str) {
+        throw unsupportedOperation("matchPath");
+    }
+
+    /**
+     * Matches a path against a pattern.
+     *
+     * @param pattern            the (non-null) pattern to match against
+     * @param str                the (non-null) string (path) to match
+     * @param isCaseSensitive    must a case sensitive match be done?
+     *
+     * @return <code>true</code> when the pattern matches against the string.
+     *         <code>false</code> otherwise.
+     */
+    protected static boolean matchPath(
+        String pattern,
+        String str,
+        boolean isCaseSensitive) {
+        throw unsupportedOperation("matchPath");
+    }
+
+    /**
+     * Matches a string against a pattern. The pattern contains two special
+     * characters:
+     * '*' which means zero or more characters,
+     * '?' which means one and only one character.
+     *
+     * @param pattern the (non-null) pattern to match against
+     * @param str     the (non-null) string that must be matched against the
+     *                pattern
+     *
+     * @return <code>true</code> when the string matches against the pattern,
+     *         <code>false</code> otherwise.
+     */
+    protected static boolean match(String pattern, String str) {
+        throw unsupportedOperation("match");
+    }
+
+    /**
+     * Matches a string against a pattern. The pattern contains two special
+     * characters:
+     * '*' which means zero or more characters,
+     * '?' which means one and only one character.
+     *
+     * @param pattern the (non-null) pattern to match against
+     * @param str     the (non-null) string that must be matched against the
+     *                pattern
+     *
+     * @return <code>true</code> when the string matches against the pattern,
+     *         <code>false</code> otherwise.
+     */
+    protected static boolean match(
+        String pattern,
+        String str,
+        boolean isCaseSensitive) {
+        throw unsupportedOperation("match");
+    }
+
+    /**
+     * Sets the basedir for scanning. This is the directory that is scanned
+     * recursively. All '/' and '\' characters are replaced by
+     * <code>File.separatorChar</code>. So the separator used need not match
+     * <code>File.separatorChar</code>.
+     *
+     * @param basedir the (non-null) basedir for scanning
+     */
+    public void setBasedir(String basedir) {
+        throw unsupportedOperation("setBasedir");
+    }
+
+    /**
+     * Sets the basedir for scanning. This is the directory that is scanned
+     * recursively.
+     *
+     * @param basedir the basedir for scanning
+     */
+    public void setBasedir(File basedir) {
+        throw unsupportedOperation("setBasedir");
+    }
+
+    /**
+     * Gets the basedir that is used for scanning. This is the directory that
+     * is scanned recursively.
+     *
+     * @return the basedir that is used for scanning
+     */
+    public File getBasedir() {
+        throw unsupportedOperation("getBasedir");
+    }
+
+    /**
+     * Sets the case sensitivity of the file system
+     *
+     * @param specifies if the filesystem is case sensitive
+     */
+    public void setCaseSensitive(boolean isCaseSensitive) {
+        throw unsupportedOperation("setCaseSensitive");
+    }
+
+    /**
+     * Sets the set of include patterns to use. All '/' and '\' characters are
+     * replaced by <code>File.separatorChar</code>. So the separator used need
+     * not match <code>File.separatorChar</code>.
+     * <p>
+     * When a pattern ends with a '/' or '\', "**" is appended.
+     *
+     * @param includes list of include patterns
+     */
+    public void setIncludes(String[] includes) {
+        throw unsupportedOperation("setIncludes");
+    }
+
+    /**
+     * Sets the set of exclude patterns to use. All '/' and '\' characters are
+     * replaced by <code>File.separatorChar</code>. So the separator used need
+     * not match <code>File.separatorChar</code>.
+     * <p>
+     * When a pattern ends with a '/' or '\', "**" is appended.
+     *
+     * @param excludes list of exclude patterns
+     */
+    public void setExcludes(String[] excludes) {
+        throw unsupportedOperation("setExcludes");
+    }
+
+    /**
+     * Scans the base directory for files that match at least one include
+     * pattern, and don't match any exclude patterns.
+     *
+     * @exception IllegalStateException when basedir was set incorrecly
+     */
+    public void scan() {
+        // deal with the filesets
+        for (int i = 0; i < filesets.size(); i++) {
+            FileSet fs = (FileSet) filesets.elementAt(i);
+            DirectoryScanner ds = fs.getDirectoryScanner(project);
+            File fromDir = fs.getDir(project);
+
+            String[] srcFiles = ds.getIncludedFiles();
+            String[] srcDirs = ds.getIncludedDirectories();
+
+            scan(fromDir, destDir, srcFiles, srcDirs);
+        }
+
+        filesIncluded = keysAsVector(destFiles);
+        filesNotIncluded = new Vector();
+        filesExcluded = new Vector();
+        dirsIncluded = keysAsVector(destDirs);
+        dirsNotIncluded = new Vector();
+        dirsExcluded = new Vector();
+    }
+
+    protected void slowScan() {
+        throw unsupportedOperation("slowScan");
+    }
+
+    protected void scandir(File dir, String vpath, boolean fast) {
+        throw unsupportedOperation("scandir");
+    }
+
+    protected boolean isIncluded(String name) {
+        throw unsupportedOperation("isIncluded");
+    }
+
+    protected boolean couldHoldIncluded(String name) {
+        throw unsupportedOperation("couldHoldIncluded");
+    }
+
+    protected boolean isExcluded(String name) {
+        throw unsupportedOperation("isExcluded");
+    }
+
+    /**
+     * Get the names of the files that matched at least one of the include
+     * patterns, and matched none of the exclude patterns.
+     * The names are relative to the basedir.
+     *
+     * @return the names of the files
+     */
+    public String[] getIncludedFiles() {
+        return super.getIncludedFiles();
+    }
+
+    public String[] getNotIncludedFiles() {
+        throw unsupportedOperation("getNotIncludedFiles");
+    }
+
+    public String[] getExcludedFiles() {
+        throw unsupportedOperation("getExcludedFiles");
+    }
+
+    /**
+     * Get the names of the directories that matched at least one of the 
include
+     * patterns, an matched none of the exclude patterns.
+     * The names are relative to the basedir.
+     *
+     * @return the names of the directories
+     */
+    public String[] getIncludedDirectories() {
+        return super.getIncludedDirectories();
+    }
+
+    public String[] getNotIncludedDirectories() {
+        throw unsupportedOperation("getNotIncludedDirectories");
+    }
+
+    public String[] getExcludedDirectories() {
+        throw unsupportedOperation("getExcludedDirectories");
+    }
+
+    public void addDefaultExcludes() {
+        throw unsupportedOperation("addDefaultExcludes");
+    }
+
+    /**
+     * Compares source files to destination files to see if they should be
+     * copied.
+     */
+    protected void scan(File fromDir, File toDir, String[] files, String[] 
dirs) {
+        FileNameMapper mapper = null;
+        if (mapperElement != null) {
+            mapper = mapperElement.getImplementation();
+        } else if (flatten) {
+            mapper = new FlatFileNameMapper();
+        } else {
+            mapper = new IdentityMapper();
+        }
+
+        buildMap(fromDir, toDir, files, mapper, destFiles);
+
+        if (includeEmpty) {
+            buildMap(fromDir, toDir, dirs, mapper, destDirs);
+        }
+    }
+
+    protected void buildMap(
+        File fromDir,
+        File toDir,
+        String[] names,
+        FileNameMapper mapper,
+        Hashtable map) {
+
+        String[] toCopy = null;
+        if (!skipUptodate) {
+            Vector v = new Vector();
+            for (int i = 0; i < names.length; i++) {
+                if (mapper.mapFileName(names[i]) != null) {
+                    v.addElement(names[i]);
+                }
+            }
+            toCopy = new String[v.size()];
+            v.copyInto(toCopy);
+        } else {
+            Task task = new NullTask();
+            task.setProject(project);
+            SourceFileScanner ds = new SourceFileScanner(task);
+            toCopy = ds.restrict(names, fromDir, toDir, mapper);
+        }
+
+        for (int i = 0; i < toCopy.length; i++) {
+            String copied = mapper.mapFileName(toCopy[i])[0];
+            File src = new File(fromDir, toCopy[i]);
+            File dest = new File(toDir, copied);
+            if (!(skipSelf && src.equals(dest))) {
+                // Store copied as a key to avoid duplicate entries.
+                map.put(copied, "");
+            }
+        }
+    }
+
+    protected Vector keysAsVector(Hashtable map) {
+        Vector v = new Vector();
+        for (Enumeration en = map.keys(); en.hasMoreElements();) {
+            Object key = en.nextElement();
+            v.addElement(key);
+        }
+        return v;
+    }
+
+    /**
+     * Creates an exception that indicates that an operation is unsupported
+     * in MappedDirectoryScanner.
+     * @param name the operation name
+     */
+    protected static BuildException unsupportedOperation(String name) {
+        return new BuildException(
+            "Unsupported operation " + name + "() in MappedDirectoryScanner");
+    }
+
+    /**
+     * Just for logging.
+     */
+    protected static class NullTask extends Task {
+    }
+}
diff -r -u -N 
jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/taskdefs/Delete.java
jakarta-ant-1.4.1/src/main/org/apache/tools/ant/taskdefs/Delete.java
--- jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/taskdefs/Delete.java 
Thu Oct 11 22:58:28 2001
+++ jakarta-ant-1.4.1/src/main/org/apache/tools/ant/taskdefs/Delete.java Sat 
Jan 26 02:32:10 2002
@@ -78,6 +78,7 @@
     protected File file = null;
     protected File dir = null;
     protected Vector filesets = new Vector();
+    protected Vector mappedfilesets = new Vector();
     protected boolean usedMatchingTask = false;
     protected boolean includeEmpty = false;     // by default, remove matching 
empty dirs

@@ -155,6 +156,13 @@
         filesets.addElement(set);
     }

+   /**
+     * Adds a set of mapped files (nested fileset attribute).
+     */
+    public void addMappedfileset(MappedFileSet set) {
+        mappedfilesets.addElement(set);
+    }
+
     /**
      * add a name entry on the include list
      */
@@ -243,8 +251,8 @@
             log("DEPRECATED - Use of the implicit FileSet is deprecated.  Use 
a nested fileset element instead.");
         }

-        if (file == null && dir == null && filesets.size() == 0) {
-            throw new BuildException("At least one of the file or dir 
attributes, or a fileset element, must be set.");
+        if (file == null && dir == null && filesets.size() == 0 && 
mappedfilesets.size() == 0) {
+            throw new BuildException("At least one of the file or dir 
attributes, a fileset element, or a mapped fileset element,
must be set.");
         }

         if (quiet && failonerror) {
@@ -293,6 +301,25 @@
         // delete the files in the filesets
         for (int i=0; i<filesets.size(); i++) {
             FileSet fs = (FileSet) filesets.elementAt(i);
+            try {
+                DirectoryScanner ds = fs.getDirectoryScanner(project);
+                String[] files = ds.getIncludedFiles();
+                String[] dirs = ds.getIncludedDirectories();
+                removeFiles(fs.getDir(project), files, dirs);
+            } catch (BuildException be) {
+                // directory doesn't exist or is not readable
+                if (failonerror) {
+                    throw be;
+                } else {
+                    log(be.getMessage(),
+                        quiet ? Project.MSG_VERBOSE : Project.MSG_WARN);
+                }
+            }
+        }
+
+        // delete the files in the mappedfilesets
+        for (int i=0; i<mappedfilesets.size(); i++) {
+            FileSet fs = (FileSet) mappedfilesets.elementAt(i);
             try {
                 DirectoryScanner ds = fs.getDirectoryScanner(project);
                 String[] files = ds.getIncludedFiles();
diff -r -u -N 
jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/types/MappedFileSet.java
jakarta-ant-1.4.1/src/main/org/apache/tools/ant/types/MappedFileSet.java
--- 
jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/types/MappedFileSet.java 
Thu Jan  1 09:00:00 1970
+++ jakarta-ant-1.4.1/src/main/org/apache/tools/ant/types/MappedFileSet.java 
Sat Jan 26 03:08:00 2002
@@ -0,0 +1,262 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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 "The Jakarta Project", "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 [EMAIL PROTECTED]
+ *
+ * 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
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.tools.ant.types;
+
+import java.io.File;
+import java.util.Stack;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.FileScanner;
+import org.apache.tools.ant.MappedDirectoryScanner;
+import org.apache.tools.ant.Project;
+
+/**
+ * Mapped file set.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Hiroaki Nakamura</a>
+ */
+public class MappedFileSet extends FileSet {
+    protected File destDir = null; // the destination directory
+    protected Vector filesets = new Vector();
+    protected Mapper mapperElement = null;
+    protected boolean includeEmpty = true;
+    protected boolean skipSelf = true;
+    protected boolean skipUptodate = false;
+
+    public MappedFileSet() {
+        super();
+    }
+
+    /**
+     * Sets the destination directory.
+     */
+    public void setTodir(File destDir) {
+        this.destDir = destDir;
+    }
+
+    /**
+     * Adds a set of files (nested fileset attribute).
+     */
+    public void addFileset(FileSet set) {
+        filesets.addElement(set);
+    }
+
+    /**
+     * Defines the FileNameMapper to use (nested mapper element).
+     */
+    public Mapper createMapper() throws BuildException {
+        if (mapperElement != null) {
+            throw new BuildException("Cannot define more than one mapper in 
<mappedfileset> elements");
+        }
+        mapperElement = new Mapper(project);
+        return mapperElement;
+    }
+
+    /**
+     * Used to copy empty directories.
+     */
+    public void setIncludeEmptyDirs(boolean includeEmpty) {
+        this.includeEmpty = includeEmpty;
+    }
+
+    /**
+     * Skip destination files which are mapped from themselves.
+     */
+    public void setSkipself(boolean skipSelf) {
+        this.skipSelf = skipSelf;
+    }
+
+    /**
+     * Skip destination files which are up-to-date.
+     */
+    public void setSkipUptodate(boolean skipUptodate) {
+        this.skipUptodate = skipSelf;
+    }
+
+    public void setDir(File dir) throws BuildException {
+        throw unsupportedAttribute("dir");
+    }
+
+    public File getDir(Project p) throws BuildException {
+        return destDir;
+    }
+
+    public PatternSet createPatternSet() throws BuildException {
+        throw unsupportedNestedElement("patternset");
+    }
+
+    public PatternSet.NameEntry createInclude() throws BuildException {
+        throw unsupportedNestedElement("include");
+    }
+
+    public PatternSet.NameEntry createIncludesFile() throws BuildException {
+        throw unsupportedAttribute("includesfile");
+    }
+
+    public PatternSet.NameEntry createExclude() throws BuildException {
+        throw unsupportedNestedElement("exclude");
+    }
+
+    public PatternSet.NameEntry createExcludesFile() throws BuildException {
+        throw unsupportedAttribute("excludesfile");
+    }
+
+    public void setIncludes(String includes) throws BuildException {
+        throw unsupportedAttribute("includes");
+    }
+
+    public void setExcludes(String excludes) throws BuildException {
+        throw unsupportedAttribute("excludes");
+    }
+
+    public void setIncludesfile(File incl) throws BuildException {
+        throw unsupportedAttribute("includesfile");
+    }
+
+    public void setExcludesfile(File excl) throws BuildException {
+        throw unsupportedAttribute("excludesfile");
+    }
+
+    public void setDefaultexcludes(boolean useDefaultExcludes)
+        throws BuildException {
+        throw unsupportedAttribute("defaultexcludes");
+    }
+
+    public void setCaseSensitive(boolean isCaseSensitive) throws 
BuildException {
+        throw unsupportedAttribute("casesensitive");
+    }
+
+    /**
+     * Returns the directory scanner needed to access the files to process.
+     */
+    public DirectoryScanner getDirectoryScanner(Project p) {
+        if (isReference()) {
+            return getRef(p).getDirectoryScanner(p);
+        }
+
+        if (destDir == null) {
+            throw new BuildException("No directory specified for fileset.");
+        }
+
+        if (!destDir.exists()) {
+            throw new BuildException(destDir.getAbsolutePath() + " not 
found.");
+        }
+        if (!destDir.isDirectory()) {
+            throw new BuildException(destDir.getAbsolutePath() + " is not a 
directory.");
+        }
+
+        DirectoryScanner ds = new MappedDirectoryScanner();
+        setupDirectoryScanner(ds, p);
+        ds.scan();
+        return ds;
+    }
+
+    public void setupDirectoryScanner(FileScanner ds, Project p) {
+        if (ds == null) {
+            throw new IllegalArgumentException("ds cannot be null");
+        }
+
+        MappedDirectoryScanner mds = (MappedDirectoryScanner) ds;
+        mds.setProject(p);
+        mds.setTodir(destDir);
+        mds.setFilesets(filesets);
+        mds.setMapper(mapperElement);
+        mds.setIncludeEmptyDirs(includeEmpty);
+        mds.setSkipself(skipSelf);
+        mds.setSkipUptodate(skipUptodate);
+    }
+
+    /**
+     * Performs the check for circular references and returns the
+     * referenced FileSet.
+     */
+    protected FileSet getRef(Project p) {
+        if (!checked) {
+            Stack stk = new Stack();
+            stk.push(this);
+            dieOnCircularReference(stk, p);
+        }
+
+        Object o = ref.getReferencedObject(p);
+        if (!(o instanceof MappedFileSet)) {
+            String msg = ref.getRefId() + " doesn\'t denote a mappedfileset";
+            throw new BuildException(msg);
+        } else {
+            return (FileSet) o;
+        }
+    }
+
+    /**
+     * Creates an exception that indicates that an attribute is unsupported
+     * in &lt;mappedfileset&gt; elements.
+     * @param name the attribute name
+     */
+    protected BuildException unsupportedAttribute(String name) {
+        return new BuildException(
+            "Attribute '" + name + "' is unsupported in <mappedfileset> 
elements");
+    }
+
+    /**
+     * Creates an exception that indicates that a nested element is unsupported
+     * in &lt;mappedfileset&gt; elements.
+     * @param name the nested element name
+     */
+    protected BuildException unsupportedNestedElement(String name) {
+        return new BuildException(
+            "Nested element <" + name + "> is unsupported in <mappedfileset> 
elements");
+    }
+}
diff -r -u -N 
jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/types/defaults.properties
jakarta-ant-1.4.1/src/main/org/apache/tools/ant/types/defaults.properties
--- 
jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/types/defaults.properties 
Thu Oct 11 22:58:29 2001
+++ jakarta-ant-1.4.1/src/main/org/apache/tools/ant/types/defaults.properties 
Sat Jan 26 03:33:21 2002
@@ -2,6 +2,7 @@
 fileset=org.apache.tools.ant.types.FileSet
 filelist=org.apache.tools.ant.types.FileList
 patternset=org.apache.tools.ant.types.PatternSet
+mappedfileset=org.apache.tools.ant.types.MappedFileSet
 mapper=org.apache.tools.ant.types.Mapper
 filterset=org.apache.tools.ant.types.FilterSet
 description=org.apache.tools.ant.types.Description



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to