<project name="if-else-tests" basedir=".">
<property name="foo" value="true"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<!-- - - - - - - - - - - - - - - - - -
target: if-else
- - - - - - - - - - - - - - - - - -->
<target name="if-else">
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is bar" />
</then>
<else>
<echo message="The value of property foo is not bar" />
</else>
</if>
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is 'bar'" />
</then>
<elseif>
<equals arg1="${foo}" arg2="foo" />
<then>
<echo message="The value of property foo is 'foo'" />
</then>
</elseif>
<else>
<echo message="The value of property foo is not 'foo' or 'bar'" />
</else>
</if>
</target>
</project>
<property name="foo" value="true"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<!-- - - - - - - - - - - - - - - - - -
target: if-else
- - - - - - - - - - - - - - - - - -->
<target name="if-else">
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is bar" />
</then>
<else>
<echo message="The value of property foo is not bar" />
</else>
</if>
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is 'bar'" />
</then>
<elseif>
<equals arg1="${foo}" arg2="foo" />
<then>
<echo message="The value of property foo is 'foo'" />
</then>
</elseif>
<else>
<echo message="The value of property foo is not 'foo' or 'bar'" />
</else>
</if>
</target>
</project>