Search code examples
antant-contrib

to check if the file is available or not in ant


Requirement : to check if the file is available or not and then based on true or false value perform some task.

I am using task:

<varNested name="path" value="/user1/abc.jar"/>
<available file="${path}" property="file.available"/>

Problem 1: Now when I am trying to print this property:

<echo message="value of file is available is : ${file.available}"/>

rather than printing the value true it prints ${file.available}

Problem 2: Will this code snippet work? if not, what shall be used instead of equalsNested? ...

        </then>
        <else>
           ...
        </else>
        </if>

Solution

  • Try this:

    <property name="abc" value="false" />
    <available file="somefile" property="abc" value="true"/>
    <echo message="value of file is available is : ${abc}"/>