From 14770e40d56326507876f30b20ea4494f441694f Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Wed, 10 Jan 2007 22:34:45 +0000 Subject: [PATCH] as discussed on dev@, allow to refer to a FileNameMapper git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@495014 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 2 + .../org/apache/tools/ant/types/Mapper.java | 15 +++++++- src/tests/antunit/types/mapper-ref.xml | 38 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/tests/antunit/types/mapper-ref.xml diff --git a/WHATSNEW b/WHATSNEW index 194051d34..6978db9a7 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -55,6 +55,8 @@ Other changes: * Show Previous Revision in the tagdiff.xsl stylesheet Bugzilla 29143 +* Allow to refer directly to a FileNameMapper instance. + Changes from Ant 1.6.5 to Ant 1.7.0 =================================== diff --git a/src/main/org/apache/tools/ant/types/Mapper.java b/src/main/org/apache/tools/ant/types/Mapper.java index 754310382..8ab3a50cc 100644 --- a/src/main/org/apache/tools/ant/types/Mapper.java +++ b/src/main/org/apache/tools/ant/types/Mapper.java @@ -198,7 +198,18 @@ public class Mapper extends DataType implements Cloneable { */ public FileNameMapper getImplementation() throws BuildException { if (isReference()) { - return getRef().getImplementation(); + dieOnCircularReference(); + Reference r = getRefid(); + Object o = r.getReferencedObject(getProject()); + if (o instanceof FileNameMapper) { + return (FileNameMapper) o; + } + if (o instanceof Mapper) { + return ((Mapper) o).getImplementation(); + } + String od = o == null ? "null" : o.getClass().getName(); + throw new BuildException(od + " at reference '" + + r.getRefId() + "' is not a valid mapper reference."); } if (type == null && classname == null && container == null) { @@ -256,6 +267,8 @@ public class Mapper extends DataType implements Cloneable { /** * Performs the check for circular references and returns the * referenced Mapper. + * @deprecated since Ant 1.7.1 because a mapper might ref a + * FileNameMapper implementation directly. * @return the referenced Mapper */ protected Mapper getRef() { diff --git a/src/tests/antunit/types/mapper-ref.xml b/src/tests/antunit/types/mapper-ref.xml new file mode 100644 index 000000000..47570c56a --- /dev/null +++ b/src/tests/antunit/types/mapper-ref.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +