Ant if else condition?

后端 未结 5 1278
傲寒
傲寒 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:26

    The quirky syntax using conditions on the target (described by Mads) is the only supported way to perform conditional execution in core ANT.

    ANT is not a programming language and when things get complicated I choose to embed a script within my build as follows:

    
        
            if (properties["some.condition"] == "true") {
                ant.copy(file:"${properties["some.dir"]}/true", todir:".")
            }
        
    
    

    ANT supports several languages (See script task), my preference is Groovy because of it's terse syntax and because it plays so well with the build.

    Apologies, David I am not a fan of ant-contrib.

提交回复
热议问题