ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r436992 - in /ant/core/trunk: ./ src/etc/testcases/types/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/types/ src/main/org/apache/tools/ant/util/ src/testcases/org/apache/tools/ant/types/
Date Fri, 25 Aug 2006 22:36:24 GMT
Author: peterreilly
Date: Fri Aug 25 15:36:21 2006
New Revision: 436992

URL: http://svn.apache.org/viewvc?rev=436992&view=rev
Log:
fix for 40228, add code to introspectionhelper to make addconfigured higher priority than
add, and add addconfigured to chainedmapper

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/etc/testcases/types/addtype.xml
    ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/Mapper.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/ContainerMapper.java
    ant/core/trunk/src/testcases/org/apache/tools/ant/types/AddTypeTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=436992&r1=436991&r2=436992&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Aug 25 15:36:21 2006
@@ -258,6 +258,9 @@
 * Copy of UnknownElement in macroinstance was not recursive.
   Bugzilla report 40238.
 
+* mixing of add and addConfigured methods in Mapper/ChainedMapper
+  causes incorrect chaining. Bugzilla report 40228.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/etc/testcases/types/addtype.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/types/addtype.xml?rev=436992&r1=436991&r2=436992&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/types/addtype.xml (original)
+++ ant/core/trunk/src/etc/testcases/types/addtype.xml Fri Aug 25 15:36:21 2006
@@ -68,6 +68,9 @@
              name = "myaddconfigured" 
              classname="${nested.package}AddTypeTest$MyAddConfigured"/>
     <typedef loaderref="nested.loader"
+             name = "myaddconfiguredvalue" 
+             classname="${nested.package}AddTypeTest$MyAddConfiguredValue"/>
+    <typedef loaderref="nested.loader"
              name = "myvalue" 
              classname="${nested.package}AddTypeTest$MyValue"/>
   </target>
@@ -125,6 +128,12 @@
     <myaddconfigured>
       <myvalue>Value Set</myvalue>
     </myaddconfigured>
+  </target>
+
+  <target name="myaddconfiguredvalue" depends="init">
+    <myaddconfiguredvalue>
+      <value>Value Set</value>
+    </myaddconfiguredvalue>
   </target>
 
   <target name="namespacetest" xmlns:prefix="uri">

Modified: ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java?rev=436992&r1=436991&r2=436992&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java Fri Aug 25 15:36:21
2006
@@ -267,7 +267,16 @@
                         constructor =
                             args[0].getConstructor(new Class[] {Project.class});
                     }
+
                     String propName = getPropertyName(name, "add");
+                    if (nestedTypes.get(propName) != null) {
+                        /*
+                         *  Ignore this method as there is an addConfigured
+                         *  form of this method that has a higher
+                         *  priority
+                         */
+                        continue;
+                    }
                     nestedTypes.put(propName, args[0]);
                     nestedCreators.put(propName, new AddNestedCreator(m,
                         constructor, AddNestedCreator.ADD));
@@ -1439,6 +1448,8 @@
      * the addTypeMethods array. The array is
      * ordered so that the more derived classes
      * are first.
+     * If both add and addConfigured are present, the addConfigured
+     * will take priority.
      * @param method the <code>Method</code> to insert.
      */
     private void insertAddTypeMethod(Method method) {
@@ -1446,6 +1457,10 @@
         for (int c = 0; c < addTypeMethods.size(); ++c) {
             Method current = (Method) addTypeMethods.get(c);
             if (current.getParameterTypes()[0].equals(argClass)) {
+                if (method.getName().equals("addConfigured")) {
+                    // add configured replaces the add method
+                    addTypeMethods.set(c, method);
+                }
                 return; // Already present
             }
             if (current.getParameterTypes()[0].isAssignableFrom(

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Mapper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Mapper.java?rev=436992&r1=436991&r2=436992&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/Mapper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/Mapper.java Fri Aug 25 15:36:21 2006
@@ -58,6 +58,15 @@
     }
 
     /**
+     * Cannot mix add and addconfigured in same type, so
+     * provide this to override the add method.
+     * @param fileNameMapper   the <code>FileNameMapper</code> to add.
+     */
+    public void addConfigured(FileNameMapper fileNameMapper) {
+        add(fileNameMapper);
+    }
+
+    /**
      * Add a nested <code>FileNameMapper</code>.
      * @param fileNameMapper   the <code>FileNameMapper</code> to add.
      */

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ContainerMapper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ContainerMapper.java?rev=436992&r1=436991&r2=436992&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ContainerMapper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ContainerMapper.java Fri Aug 25 15:36:21
2006
@@ -41,6 +41,19 @@
     }
 
     /**
+     * An add configured version of the add method.
+     * This class used to contain an add method and an
+     * addConfiguredMapper method. Dur to ordering,
+     * the add method was always called first. This
+     * addConfigued method has been added to allow
+     * chaining to work correctly.
+     * @param fileNameMapper a <code>FileNameMapper</code>.
+     */
+    public void addConfigured(FileNameMapper fileNameMapper) {
+        add(fileNameMapper);
+    }
+
+    /**
      * Add a <code>FileNameMapper</code>.
      * @param fileNameMapper a <code>FileNameMapper</code>.
      * @throws IllegalArgumentException if attempting to add this

Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/types/AddTypeTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/testcases/org/apache/tools/ant/types/AddTypeTest.java?rev=436992&r1=436991&r2=436992&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/types/AddTypeTest.java (original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/types/AddTypeTest.java Fri Aug 25 15:36:21
2006
@@ -18,6 +18,7 @@
 package org.apache.tools.ant.types;
 
 import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.taskdefs.condition.Condition;
@@ -86,6 +87,12 @@
             "myaddconfigured", "value is Value Setexecute: value is Value Set");
     }
 
+    public void testAddConfiguredValue() {
+        expectLogContaining(
+            "myaddconfiguredvalue",
+            "value is Value Setexecute: value is Value Set");
+    }
+
     public void testNamespace() {
         executeTarget("namespacetest");
     }
@@ -150,6 +157,25 @@
         public void addConfigured(MyValue value) {
             log("value is " + value);
             this.value = value;
+        }
+        public void add(MyValue value) {
+            throw new BuildException("Should not be called");
+        }
+        public void execute() {
+            log("execute: value is " + value);
+        }
+    }
+
+    public static class MyAddConfiguredValue
+        extends Task
+    {
+        MyValue value;
+        public void addConfiguredValue(MyValue value) {
+            log("value is " + value);
+            this.value = value;
+        }
+        public void addValue(MyValue value) {
+            throw new BuildException("Should not be called");
         }
         public void execute() {
             log("execute: value is " + value);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message