1. 下载antcontrib jar
在编译脚本里加上
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="D:/ab/ant-con.jar" /> <!-- 下载下来jar包的存放路径
</classpath>
</taskdef>
经常碰到这个错误:
[taskdef] Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.
参考这个链接 完美解决
http://stackoverflow.com/questions/8406332/ant-contrib-needed-in-1-8-2-build-xml-but-causes-errors
贴上一个成功的例子
<project name="test" basedir="." default="init">
<target name="init">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="D:/ab/ant-con.jar" />
</classpath>
</taskdef>
<if>
<contains string="mmm" substring="us" />
<then>
<echo>bbbbbbbbb!!!!!!!!!!!!!</echo>
</then>
<else>
<echo>bbbbbbbbb</echo>
</else>
</if>
</target>
</project>