You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2005/03/10 17:13:13 UTC

cvs commit: ant/src/etc/testcases/taskdefs condition.xml

mbenson     2005/03/10 08:13:13

  Modified:    .        Tag: ANT_16_BRANCH WHATSNEW
               docs/manual/CoreTasks Tag: ANT_16_BRANCH condition.html
               src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH
                        ConditionTask.java
               src/testcases/org/apache/tools/ant/taskdefs Tag:
                        ANT_16_BRANCH ConditionTest.java
               src/etc/testcases/taskdefs Tag: ANT_16_BRANCH condition.xml
  Log:
  Merge condition else="" from HEAD.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.503.2.191 +4 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.190
  retrieving revision 1.503.2.191
  diff -u -r1.503.2.190 -r1.503.2.191
  --- WHATSNEW	10 Mar 2005 14:23:40 -0000	1.503.2.190
  +++ WHATSNEW	10 Mar 2005 16:13:11 -0000	1.503.2.191
  @@ -107,6 +107,10 @@
   * Added verbose="true|false" attribute to <subant>. When verbose is enabled,
     the directory name is logged on entry and exit of the sub-build. Bugzilla 33787.
   
  +* Add else attribute to the condition task, which specifies an
  +  optional alternate value to set the property to if the nested
  +  condition evaluates to false. Bugzilla report 33074.
  +
   Fixed bugs:
   -----------
   
  
  
  
  No                   revision
  No                   revision
  1.13.2.3  +9 -1      ant/docs/manual/CoreTasks/condition.html
  
  Index: condition.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/condition.html,v
  retrieving revision 1.13.2.2
  retrieving revision 1.13.2.3
  diff -u -r1.13.2.2 -r1.13.2.3
  --- condition.html	9 Feb 2004 22:12:07 -0000	1.13.2.2
  +++ condition.html	10 Mar 2005 16:13:13 -0000	1.13.2.3
  @@ -37,6 +37,14 @@
         &quot;true&quot;.</td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">else</td>
  +    <td valign="top">The value to set the property to if the condition
  +      evaluates to <i>false</i>. By default the property will remain unset.
  +      <em>Since Ant 1.6.3</em>
  +    </td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
   </table>
   <h3><a name="nested">Parameters specified as nested elements</a></h3>
   <p>All conditions to test are specified as nested elements, for a
  @@ -81,7 +89,7 @@
   operating system is SunOS and if it is running on a sparc architecture.</p>
   
   <hr>
  -<p align="center">Copyright &copy; 2001-2002,2004 The Apache Software
  +<p align="center">Copyright &copy; 2001-2002, 2004-2005 Apache Software
   Foundation. All rights Reserved.</p>
   
   </body>
  
  
  
  No                   revision
  No                   revision
  1.16.2.6  +15 -1     ant/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
  
  Index: ConditionTask.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java,v
  retrieving revision 1.16.2.5
  retrieving revision 1.16.2.6
  diff -u -r1.16.2.5 -r1.16.2.6
  --- ConditionTask.java	9 Mar 2005 18:56:25 -0000	1.16.2.5
  +++ ConditionTask.java	10 Mar 2005 16:13:13 -0000	1.16.2.6
  @@ -41,6 +41,7 @@
   
       private String property = null;
       private String value = "true";
  +    private String alternative = null;
   
       /**
        * The name of the property to set. Required.
  @@ -62,6 +63,16 @@
       }
   
       /**
  +     * The value for the property to set, if condition evaluates to false.
  +     * If this attribute is not specified, the property will not be set.
  +     * @param e the alternate value of the property.
  +     * @since Ant 1.6.3
  +     */
  +    public void setElse(String e) {
  +        alternative = e;
  +    }
  +
  +    /**
        * See whether our nested condition holds and set the property.
        *
        * @since Ant 1.4
  @@ -79,12 +90,15 @@
           if (property == null) {
               throw new BuildException("The property attribute is required.");
           }
  -
           Condition c = (Condition) getConditions().nextElement();
           if (c.eval()) {
               log("Condition true; setting " + property + " to " + value,
                   Project.MSG_DEBUG);
               getProject().setNewProperty(property, value);
  +        } else if (alternative != null) {
  +            log("Condition false; setting " + property + " to " + alternative,
  +                Project.MSG_DEBUG);
  +            getProject().setNewProperty(property, alternative);
           } else {
               log("Condition false; not setting " + property,
                   Project.MSG_DEBUG);
  
  
  
  No                   revision
  No                   revision
  1.6.2.5   +4 -1      ant/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java
  
  Index: ConditionTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java,v
  retrieving revision 1.6.2.4
  retrieving revision 1.6.2.5
  diff -u -r1.6.2.4 -r1.6.2.5
  --- ConditionTest.java	9 Mar 2004 17:02:01 -0000	1.6.2.4
  +++ ConditionTest.java	10 Mar 2005 16:13:13 -0000	1.6.2.5
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2002,2004 The Apache Software Foundation
  + * Copyright  2002, 2004-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.
  @@ -226,5 +226,8 @@
                       "Nothing to test for falsehood");
       }
   
  +    public void testElse() {
  +        executeTarget("testElse");
  +    }
   }
   
  
  
  
  No                   revision
  No                   revision
  1.3.2.1   +25 -0     ant/src/etc/testcases/taskdefs/condition.xml
  
  Index: condition.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/condition.xml,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- condition.xml	1 Jun 2002 12:26:36 -0000	1.3
  +++ condition.xml	10 Mar 2005 16:13:13 -0000	1.3.2.1
  @@ -347,6 +347,31 @@
       </condition>
       <echo>${isfalse-incomplete}</echo>
     </target>
  +
  +  <target name="testElse">
  +    <condition property="unset" value="foo">
  +      <or />
  +    </condition>
  +    <condition property="value" value="foo" else="bar">
  +      <and />
  +    </condition>
  +    <condition property="else" value="foo" else="bar">
  +      <or />
  +    </condition>
  +    <fail>
  +      <condition>
  +        <or>
  +          <isset property="unset" />
  +          <not>
  +            <and>
  +              <equals arg1="${value}" arg2="foo" />
  +              <equals arg1="${else}" arg2="bar" />
  +            </and>
  +          </not>
  +        </or>
  +      </condition>
  +    </fail>
  +  </target>
     
     <target name="cleanup" >
       <delete file="match1.txt" />
  
  
  

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