Ant if else condition?

后端 未结 5 1281
傲寒
傲寒 2020-12-13 13:03

Is there an if/else condition that I can use for an Ant task?

This is what i have written so far:



        
5条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 13:34

    The if attribute does not exist for . It should be applied to the .

    Below is an example of how you can use the depends attribute of a target and the if and unless attributes to control execution of dependent targets. Only one of the two should execute.

    
    
    
    
        Get file based on condition being true
        
    
    
    
        Get file based on condition being false
        
    
    

    If you are using ANT 1.8+, then you can use property expansion and it will evaluate the value of the property to determine the boolean value. So, you could use if="${copy-condition}" instead of if="copy-condition".

    In ANT 1.7.1 and earlier, you specify the name of the property. If the property is defined and has any value (even an empty string), then it will evaluate to true.

提交回复
热议问题