ANT和文件或目录 [英] ANT and file or directories
本文介绍了ANT和文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在ant中遍历一个目录级别吗?
我是说
Can i iterate over one directory level in ant??
I mean to say
*DIR
-->dir1
---->file1
---->file2
---->file3
-->dir2
---->file1
---->file2
---->file3
-->dir3
---->file1
我想要的是dir1 dir2 dir3?
What i want is dir1 dir2 dir3 ??
<!-- Script -->
<target name="forloop">
<ac:foreach target="trimmer" param="file" xmlns:ac="#unknown">
<path>
<fileset dir="${directory}/SourceFolder/" includes="**/*">
<depth max="1" />
</fileset>
</path>
</ac:foreach>
</target>
<target name="trimmer">
<echo message="${file}" />
</target>
但这给了我一级文件而不是一级目录.
我如何改善它?
But this gives me first level files not first level directories.
How can i improve it ??
推荐答案
{directory}/SourceFolder/" 包括 =" //" > < 深度 =" 1" / < /fileset > < /path > < /ac:foreach > < /target > < 目标 =" trimmer" < echo ="
{directory}/SourceFolder/" includes="**/*"> <depth max="1" /> </fileset> </path> </ac:foreach> </target> <target name="trimmer"> <echo message="
{file} " / < /target >
{file}" /> </target>
但这给了我一级文件而不是一级目录.
我该如何改善它?
But this gives me first level files not first level directories.
How can i improve it ??
根据ant-contrib文档,它不返回文件集而不是使用代码集,而是返回目录.
因此,您的for循环将类似于:
Instead of using a fileset for your code why don''t you use the dirset, according to the ant-contrib documentation this should return directories.
So your for loop would look something like:
<ac:foreach target="trimmer" param="file" xmlns:ac="#unknown">
<path>
<dirset dir="="
这篇关于ANT和文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文