javaantant-contrib

Ant else condition execution


I am trying to print some message in Ant depending on some condition as follow:

<if>
    <equals arg1="${docs.present}" arg2="true"/>
    <then>
    </then>
    <else>
        <echo message="No docss found!"/>
    </else>
</if>

But as you see, if docs.present property is set to 'true' then only I want to execute only else part. There is nothing to execute in if part. How can I achieve this?


Solution

  • You can use echo in your if condition instead of else as below :

    <if>
        <equals arg1="${docs.present}" arg2="false"/>
        <then>
              <echo message="No docss found!"/>
        </then>
    </if>