1、propertyregex
字符串截取:
<property name="var" value="1.0/test/l" />
<propertyregex property="version" input="${var}" regexp="(.*)/(.*)/(.*)" select="\1" />
<propertyregex property="env" input="${var}" regexp="(.*)/(.*)/(.*)" select="\2" />
<propertyregex property="log" input="${var}" regexp="(.*)/(.*)/(.*)" select="\3" />
<echo>version:${version} env:${env} log:${log}</echo>
2、var、if
判断变量是否相等
<var name="var1" value="test1" />
<var name="var2" value="test2" />
<if>
<condition>
<equals arg1="${var1}" arg2="${var2}" />
</condition>
<then>
<echo>var1 is equal to var2</echo>
</then>
<else>
<echo>var1 is not equal to var2</echo>
</else>
</if>
参考:
http://crppztl.iteye.com/blog/332832
http://ant-contrib.sourceforge.net/