<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="antBuildDoc.xsl"?>
<!--
这是完整的例子
ant 实现循环
循环主要是依靠xsl实现
必须将ant-contrib.jar添加到classpath
我把ant-contrib.jar放在E:\jar\ant1.8\lib目录下)
set ant_home=E:\jar\ant1.8
set path=%path%;%ant_home%\bin
-->
<project name="v3" default="copy" basedir=".">
<!--必须定义这个标签-->
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<property name="sourceBase" value="a,bb,cc,dd,ee"/>
<target name='copy'>
<for list="${sourceBase}" param="srcbase">
<sequential>
<echo message="循环输出:@{srcbase}" />
</sequential>
</for>
</target>
</project>
输出结果:
[echo] 循环输出:a
[echo] 循环输出:bb
[echo] 循环输出:cc
[echo] 循环输出:dd
[echo] 循环输出:ee
另一个种用法:
<target name="clean-themes">
<for param="module.name">
<path>
<dirset dir="docroot/html/themes" excludes="_styled,_unstyled" includes="*" />
</path>
<sequential>
<echo message="@{module.name}"/>
<delete includeemptydirs="true" quiet="true" failonerror="false">
<fileset
dir="@{module.name}"
excludes="**/_diffs/**"
/>
</delete>
</sequential>
</for>
</target>
这可以删除docroot/html/themes目录下除了_styled和_unstyled目录的所有目录