Reported by: Matthew Nelson git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277378 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -258,6 +258,8 @@ Fixed bugs: | |||||
| * forked <javac> won't pass -source to a JDK 1.1 or 1.2 javac anymore. | * forked <javac> won't pass -source to a JDK 1.1 or 1.2 javac anymore. | ||||
| Bugzilla report 32948 | Bugzilla report 32948 | ||||
| * propertyset references did not handle nested propertyset references. | |||||
| Changes from Ant 1.6.1 to Ant 1.6.2 | Changes from Ant 1.6.1 to Ant 1.6.2 | ||||
| =================================== | =================================== | ||||
| @@ -0,0 +1,55 @@ | |||||
| <!-- | |||||
| * Copyright 2005 The Apache Software Foundation | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| * | |||||
| --> | |||||
| <project> | |||||
| <property name="fooA" value="FooA"/> | |||||
| <property name="barB" value="BarB"/> | |||||
| <propertyset id="properties-starting-with-foo"> | |||||
| <propertyref prefix="foo"/> | |||||
| </propertyset> | |||||
| <propertyset id="properties-starting-with-bar"> | |||||
| <propertyref prefix="bar"/> | |||||
| </propertyset> | |||||
| <propertyset id="my-set"> | |||||
| <propertyset refid="properties-starting-with-foo"/> | |||||
| <propertyset refid="properties-starting-with-bar"/> | |||||
| </propertyset> | |||||
| <macrodef name="expect.equals"> | |||||
| <attribute name="test"/> | |||||
| <attribute name="exp"/> | |||||
| <attribute name="got"/> | |||||
| <sequential> | |||||
| <fail message= | |||||
| "@{test} failed: expected "@{exp}" got "@{got}""> | |||||
| <condition> | |||||
| <not> | |||||
| <equals arg1="@{exp}" arg2="@{got}"/> | |||||
| </not> | |||||
| </condition> | |||||
| </fail> | |||||
| </sequential> | |||||
| </macrodef> | |||||
| <target name="reference-to-two-references"> | |||||
| <expect.equals | |||||
| test="reference to two references" | |||||
| exp="barB=BarB, fooA=FooA" | |||||
| got="${toString:my-set}"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -19,8 +19,10 @@ package org.apache.tools.ant.types; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.Map; | |||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.Set; | import java.util.Set; | ||||
| import java.util.TreeMap; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.Stack; | import java.util.Stack; | ||||
| @@ -202,6 +204,9 @@ public class PropertySet extends DataType { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| public Properties getProperties() { | public Properties getProperties() { | ||||
| if (isReference()) { | |||||
| return getRef().getProperties(); | |||||
| } | |||||
| Set names = null; | Set names = null; | ||||
| Project prj = getProject(); | Project prj = getProject(); | ||||
| Hashtable props = | Hashtable props = | ||||
| @@ -209,11 +214,7 @@ public class PropertySet extends DataType { | |||||
| if (getDynamic() || cachedNames == null) { | if (getDynamic() || cachedNames == null) { | ||||
| names = new HashSet(); | names = new HashSet(); | ||||
| if (isReference()) { | |||||
| getRef().addPropertyNames(names, props); | |||||
| } else { | |||||
| addPropertyNames(names, props); | |||||
| } | |||||
| addPropertyNames(names, props); | |||||
| // Add this PropertySet's nested PropertySets' property names. | // Add this PropertySet's nested PropertySets' property names. | ||||
| for (Enumeration e = setRefs.elements(); e.hasMoreElements();) { | for (Enumeration e = setRefs.elements(); e.hasMoreElements();) { | ||||
| PropertySet set = (PropertySet) e.nextElement(); | PropertySet set = (PropertySet) e.nextElement(); | ||||
| @@ -375,5 +376,26 @@ public class PropertySet extends DataType { | |||||
| return new String[] {ALL, SYSTEM, COMMANDLINE}; | return new String[] {ALL, SYSTEM, COMMANDLINE}; | ||||
| } | } | ||||
| } | } | ||||
| } // END class PropertySet | |||||
| /** | |||||
| * A debug toString. | |||||
| * This gets a comma separated list of key=value pairs for | |||||
| * the properties in the set. | |||||
| * The output order is sorted according to the keys' <i>natural order</i>. | |||||
| * @return a string rep of this object | |||||
| */ | |||||
| public String toString() { | |||||
| StringBuffer b = new StringBuffer(); | |||||
| TreeMap sorted = new TreeMap(getProperties()); | |||||
| for (Iterator i = sorted.entrySet().iterator(); i.hasNext();) { | |||||
| Map.Entry e = (Map.Entry) i.next(); | |||||
| if (b.length() != 0) { | |||||
| b.append(", "); | |||||
| } | |||||
| b.append(e.getKey().toString()); | |||||
| b.append("="); | |||||
| b.append(e.getValue().toString()); | |||||
| } | |||||
| return b.toString(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,39 @@ | |||||
| /* | |||||
| * Copyright 2005 The Apache Software Foundation | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| * | |||||
| */ | |||||
| package org.apache.tools.ant.types; | |||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.BuildFileTest; | |||||
| import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.Task; | |||||
| import org.apache.tools.ant.taskdefs.condition.Condition; | |||||
| public class PropertySetTest extends BuildFileTest { | |||||
| public PropertySetTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/types/propertyset.xml"); | |||||
| } | |||||
| public void testReferenceToTwoReferences() { | |||||
| executeTarget("reference-to-two-references"); | |||||
| } | |||||
| } | |||||