antparametersexecbuild.xml

How to put condition in exec in a build.xml file?


How to put a condition in exec in a build.xml file invoked from Hudson?

I need to use arg only if something happened (I send some parameters) and I need an if task or a condition for can solve the problem.


Solution

  • The Ant Contrib library has an if task which looks like:

    <if>
    <my condition goes here>
    <then>
    </then>
    </if>
    

    In raw Ant, you use the condition task which looks like:

    <condition property="condition.to.set">
       <my condition goes here>  
    </condition>
    

    and then a conditional target:

    <target name="mine" if="condition.to.set">
    

    I prefer Ant Contrib as it is easier to read.