Skip to content

Instantly share code, notes, and snippets.

@mattkirwan
Created December 5, 2012 21:45
Show Gist options
  • Save mattkirwan/4219785 to your computer and use it in GitHub Desktop.
Save mattkirwan/4219785 to your computer and use it in GitHub Desktop.
AvailableTask value attribute - possible type inconsistencies
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="test">
<property name="dir" value="../test_directory" />
<target name="test">
<echo message="Test 1:" />
<echo message="--------------------" />
<!-- Test 1: Value attribute not declared.
Defaults to "true" (as per docs).
-->
<available file="${dir}" type="dir" property="test1.dir.exists" />
<echo message="AvailableTask value attribute: NOT SET" />
<echo message="--------------------" />
<echo message="Actual AvailableTask value: ${test1.dir.exists}" />
<echo message="--------------------" />
<echo message="If arg2 = 'true' (string)" />
<if>
<equals arg1="${test1.dir.exists}" arg2="true" />
<then>
<echo message="Pass" />
</then>
<else>
<echo message="Fail" />
</else>
</if>
<echo message="--------------------" />
<echo message="If arg2 = '1' (string)" />
<if>
<equals arg1="${test1.dir.exists}" arg2="1" />
<then>
<echo message="Pass" />
</then>
<else>
<echo message="Fail" />
</else>
</if>
<echo message="--------------------" />
<echo message="--------------------" />
<echo message="--------------------" />
<echo message="--------------------" />
<echo message="--------------------" />
<echo message="Test 2:" />
<echo message="--------------------" />
<!-- Test 2: Value attribute declared as true (assumed string type).
-->
<available file="${dir}" type="dir" property="test2.dir.exists" value="true" />
<echo message="AvailableTask value attribute: 'true' (string)" />
<echo message="--------------------" />
<echo message="Actual AvailableTask value: ${test2.dir.exists}" />
<echo message="--------------------" />
<echo message="If arg2 = 'true' (string)" />
<if>
<equals arg1="${test2.dir.exists}" arg2="true" />
<then>
<echo message="Pass." />
</then>
<else>
<echo message="Fail" />
</else>
</if>
<echo message="--------------------" />
<echo message="If arg2 = '1' (string)" />
<if>
<equals arg1="${test2.dir.exists}" arg2="1" />
<then>
<echo message="Pass" />
</then>
<else>
<echo message="Fail" />
</else>
</if>
<echo message="--------------------" />
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment