diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index 2560f8846..3bbd5cc73 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -72,6 +72,7 @@ import java.util.*; * copyfile/copydir tasks.
* * @author Glenn McAllister glennm@ca.ibm.com + * @author Stefan Bodewig */ public class Copy extends Task { protected File file = null; // the source file @@ -88,6 +89,8 @@ public class Copy extends Task { protected Hashtable fileCopyMap = new Hashtable(); protected Hashtable dirCopyMap = new Hashtable(); + protected Mapper mapperElement = null; + /** * Sets a single source file to copy. */ @@ -159,6 +162,18 @@ public class Copy extends Task { 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", + location); + } + mapperElement = new Mapper(project); + return mapperElement; + } + /** * Performs the copy operation. */ @@ -246,7 +261,9 @@ public class Copy extends Task { */ protected void scan(File fromDir, File toDir, String[] files, String[] dirs) { FileNameMapper mapper = null; - if (flatten) { + if (mapperElement != null) { + mapper = mapperElement.getImplementation(); + } else if (flatten) { mapper = new FlatFileNameMapper(); } else { mapper = new IdentityMapper();