Search code examples
antant-contrib

Available tag in ant is always true if a file is unavailable also


This code is always returning a true value even if file at given path does not exists

   <available file="${x}/schema/@{componentname}-schema.sql" type="file"      property="schema.file" />
      <if>
          <equals arg1="true" arg2="${schema.file}" />
            <then>
        <debug message="****schemafile is  ${schema.file} ******" />
            </then>
</if>

Output is always :- *schemafile is true***

even if file is not available at that path. Please help me to find the error.


Solution

  • problem was i was iterating above code in for loop, and since property is immutable, it is always set to true if set at-least once. Thats why after 1 iteration even if the file was not found, it echoes schemafile is true** .

    i have added below code to set property to false after that code

    <var name="schema.file" unset="true"/>
    <property name="schema.file" value="false"/>