ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs AntTest.java
Date Wed, 10 Sep 2003 13:57:20 GMT
peterreilly    2003/09/10 06:57:20

  Modified:    src/etc/testcases/taskdefs ant.xml
               src/main/org/apache/tools/ant/taskdefs Ant.java
               src/testcases/org/apache/tools/ant/taskdefs AntTest.java
  Added:       src/etc/testcases/taskdefs ant.topleveltest.xml
  Log:
  Changes to <ant>
     do not call the "" target (it gets run anyway)
     allow duplicate params with the same name, last
       param will be used.
  
  Test cases for above
  
  Revision  Changes    Path
  1.12      +16 -0     ant/src/etc/testcases/taskdefs/ant.xml
  
  Index: ant.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/ant.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ant.xml	4 Sep 2003 11:46:03 -0000	1.11
  +++ ant.xml	10 Sep 2003 13:57:19 -0000	1.12
  @@ -169,4 +169,20 @@
   
     <target name="middleman" depends="infinite-loop-via-depends"/>
     <target name="dependent" depends="middleman"/>
  +  
  +  <target name="multi-same-property">
  +    <ant antfile="ant.xml" target="echo-for-multi-same">
  +      <property name="prop" value="one"/>
  +      <property name="prop" value="two"/>
  +    </ant>
  +  </target>
  +
  +  <target name="echo-for-multi-same">
  +    <echo>prop is ${prop}</echo>
  +  </target>
  +
  +  <target name="topleveltarget">
  +    <ant antfile="ant.topleveltest.xml"/>
  +  </target>
  +
   </project>
  
  
  
  1.1                  ant/src/etc/testcases/taskdefs/ant.topleveltest.xml
  
  Index: ant.topleveltest.xml
  ===================================================================
  <project>
    <echo>Hello world</echo>
  </project>
  
  
  
  1.89      +18 -5     ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- Ant.java	10 Sep 2003 13:17:00 -0000	1.88
  +++ Ant.java	10 Sep 2003 13:57:19 -0000	1.89
  @@ -62,6 +62,8 @@
   import java.util.Enumeration;
   import java.util.Hashtable;
   import java.util.Vector;
  +import java.util.Set;
  +import java.util.HashSet;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.BuildListener;
   import org.apache.tools.ant.DefaultLogger;
  @@ -393,10 +395,10 @@
                       throw new BuildException(getTaskName() + " task calling "
                                                + "its own parent target.");
                   } else {
  -                    Target other = 
  +                    Target other =
                           (Target) getProject().getTargets().get(target);
                       if (other != null && other.dependsOn(owningTargetName)) {
  -                        throw new BuildException(getTaskName() 
  +                        throw new BuildException(getTaskName()
                                                    + " task calling a target"
                                                    + " that depends on"
                                                    + " its parent target \'"
  @@ -409,9 +411,9 @@
               addReferences();
   
               if (target != null) {
  -                newProject.executeTarget(target);
  -            } else {
  -                newProject.executeTarget("");
  +                if (!"".equals(target)) {
  +                    newProject.executeTarget(target);
  +                }
               }
           } finally {
               // help the gc
  @@ -441,6 +443,17 @@
        * @throws BuildException under unknown circumstances
        */
       private void overrideProperties() throws BuildException {
  +        // remove duplicate properties - last property wins
  +        // Needed for backward compatibility
  +        Set set = new HashSet();
  +        for (int i = properties.size() - 1; i >= 0; --i) {
  +            Property p = (Property) properties.get(i);
  +            if (set.contains(p.getName())) {
  +                properties.remove(i);
  +            } else {
  +                set.add(p.getName());
  +            }
  +        }
           Enumeration e = properties.elements();
           while (e.hasMoreElements()) {
               Property p = (Property) e.nextElement();
  
  
  
  1.19      +9 -1      ant/src/testcases/org/apache/tools/ant/taskdefs/AntTest.java
  
  Index: AntTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/AntTest.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AntTest.java	4 Sep 2003 11:46:03 -0000	1.18
  +++ AntTest.java	10 Sep 2003 13:57:20 -0000	1.19
  @@ -306,6 +306,14 @@
           expectBuildException("infinite-loop-via-depends", "recursive call");
       }
   
  +    public void testMultiSameProperty() {
  +        expectLog("multi-same-property", "prop is two");
  +    }
  +
  +    public void testTopLevelTarget() {
  +        expectLog("topleveltarget", "Hello world");
  +    }
  +    
       private class BasedirChecker implements BuildListener {
           private String[] expectedBasedirs;
           private int calls = 0;
  
  
  

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


Mime
View raw message