Bug 43362

Summary: Add conditional attributes
Product: Ant Reporter: Peter Reilly <peterreilly>
Component: CoreAssignee: Ant Notifications List <notifications>
Status: RESOLVED FIXED    
Severity: enhancement Keywords: PatchAvailable
Priority: P2    
Version: unspecified   
Target Milestone: 1.9.1   
Hardware: All   
OS: other   
Attachments: Patch against trunk providing the functionaly and some tests

Description Peter Reilly 2007-09-12 06:39:23 UTC
This patch allows conditional attributes to be
used to suppress evaluation of unknown elements.
This has the effect of adding conditional execution for
tasks and conditon inclusion of nested elements.

Example usage:
<project name="x" xmlns:if="ant:if" xmlns:unless="ant:unless">

  <property name="onWindows" value="true"/>

  <target name="abc">
       <echo if:set="onWindows">I am on windows</echo>
       <echo unless:set="onWindows">I am *not* on windows</echo>
  </target>
  <macrodef name="mycommand">
     <attribute name="level" default=""/>
     <attribute name="debug" default=""/>
      <attribute name="file"/>
    <sequential>
       <exec executable="mycommand">
       <arg value="--debug"  if:true="@{debug}"/>
       <arg value="--level"    unless:blank="@{level}"/>
       <arg value="@{level}"  unless:blank="@{level}"/>
       <arg value="@{file}"/>
  </sequential>
 </macrodef>

</project>
Comment 1 Peter Reilly 2007-09-12 06:40:36 UTC
Created attachment 20797 [details]
Patch against trunk providing the functionaly and some tests
Comment 2 Antoine Levy-Lambert 2013-05-05 23:53:54 UTC
committed in revision 1479422.