【转】 ant循环(for)

<?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目录的所有目录

转载于:https://my.oschina.net/aiguozhe/blog/63779

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值