git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@495014 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -55,6 +55,8 @@ Other changes: | |||||
| * Show Previous Revision in the tagdiff.xsl stylesheet | * Show Previous Revision in the tagdiff.xsl stylesheet | ||||
| Bugzilla 29143 | Bugzilla 29143 | ||||
| * Allow <mapper refid> to refer directly to a FileNameMapper instance. | |||||
| Changes from Ant 1.6.5 to Ant 1.7.0 | Changes from Ant 1.6.5 to Ant 1.7.0 | ||||
| =================================== | =================================== | ||||
| @@ -198,7 +198,18 @@ public class Mapper extends DataType implements Cloneable { | |||||
| */ | */ | ||||
| public FileNameMapper getImplementation() throws BuildException { | public FileNameMapper getImplementation() throws BuildException { | ||||
| if (isReference()) { | 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) { | 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 | * Performs the check for circular references and returns the | ||||
| * referenced Mapper. | * referenced Mapper. | ||||
| * @deprecated since Ant 1.7.1 because a mapper might ref a | |||||
| * FileNameMapper implementation directly. | |||||
| * @return the referenced Mapper | * @return the referenced Mapper | ||||
| */ | */ | ||||
| protected Mapper getRef() { | protected Mapper getRef() { | ||||
| @@ -0,0 +1,38 @@ | |||||
| <!-- does not address/replace the circular reference checks, etc. | |||||
| in MapperTest.java (yet). | |||||
| --> | |||||
| <project xmlns:au="antlib:org.apache.ant.antunit"> | |||||
| <macrodef name="test"> | |||||
| <sequential> | |||||
| <pathconvert property="dest"> | |||||
| <string value="foo" /> | |||||
| <mapper refid="mapper" /> | |||||
| </pathconvert> | |||||
| <au:assertTrue> | |||||
| <equals arg1="${dest}" arg2="bar" /> | |||||
| </au:assertTrue> | |||||
| </sequential> | |||||
| </macrodef> | |||||
| <target name="testBasic" description="success"> | |||||
| <mapper id="mapper" type="merge" to="bar" /> | |||||
| <test /> | |||||
| </target> | |||||
| <target name="testFileNameMapper" description="success"> | |||||
| <mergemapper id="mapper" to="bar" /> | |||||
| <test /> | |||||
| </target> | |||||
| <target name="testWrongType" description="failure"> | |||||
| <path id="mapper" path="whocares" /> | |||||
| <au:expectfailure | |||||
| expectedMessage="org.apache.tools.ant.types.Path at reference 'mapper' is not a valid mapper reference."> | |||||
| <test /> | |||||
| </au:expectfailure> | |||||
| </target> | |||||
| <target name="all" depends="testBasic,testFileNameMapper,testWrongType" /> | |||||
| </project> | |||||