通过蚂蚁目录结构中循环 [英] Loop through directory structure in ant
本文介绍了通过蚂蚁目录结构中循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们希望通过目录结构回路蚂蚁不使用的foreach。
是否有任何优雅的方式做同样的?
We want to loop through directory structure in ant without using foreach . Is there any elegant way to do the same ?
推荐答案
借助申请任务可以遍历一组目录或文件的
The apply task can iterate over a set of directories or files
<target name="run-apply">
<apply executable="echo">
<dirset dir="src"/>
</apply>
</target>
我个人喜欢常规Ant任务
<target name="run-groovy">
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy"/>
<dirset id="dirs" dir="src"/>
<groovy>
project.references.dirs.each {
ant.echo it
}
</groovy>
</target>
任务jar包的安装容易实现自动化:
The installation of the task jar is easily automated:
<target name="install-groovy">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/groovy-all.jar" src="http://search.maven.org/remotecontent?filepath=org/codehaus/groovy/groovy-all/2.1.1/groovy-all-2.1.1.jar"/>
</target>
最后,如果你遍历直通其他构建文件中, subant 任务是非常有用的:
<target name="run-subant">
<subant>
<fileset dir="src" includes="**/build.xml"/>
</subant>
</target>
这篇关于通过蚂蚁目录结构中循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文