Search code examples
antant-contrib

How to put two conditions in ANT Target?


My need is to check two conditions in my ANT Target. If either of them is true the ant target must execute.

<target name="generateArtifacts" if="${generateABC}" or if="${generatePQR}">
...
/>

The above syntax in WRONG. How to make it correct?


Solution

  • Maybe there's something simpler, but the following would do, I think:

    <condition property="artifactsMustBeGenerated">
        <or>
            <isTrue value="${generateABC}"/>
            <isTrue value="${generatePQR}"/>
        </or>
    </condition>
    
    <target name="generateArtifacts" if="${artifactsMustBeGenerated}">
        ...
    />