如何删除使用Ant目录的dirset? [英] How do I delete a dirset of directories with Ant?

查看:541
本文介绍了如何删除使用Ant目录的dirset?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要删除根目录是包含自己的名字TMP下的所有目录和子目录。这应该包括所有的.svn文件了。我的第一个猜测是使用

I want to delete all directories and subdirectories under a root directory that are contain "tmp" in their names. This should include any .svn files too. My first guess is to use

<delete>
    <dirset dir="${root}">
          <include name="**/*tmp*" />
    </dirset>
</delete>

这似乎并没有工作,因为你不能嵌套 dirset 删除标记。

This does not seem to work as you can't nest a dirset in a delete tag.

这是一个正确的做法,或者我应该做点别的?

Is this a correct approach, or should I be doing something else?


  • 蚂蚁版本1.6.5 ==

  • Java版本1.6.0_04 ==

推荐答案

下面是为我工作了答案:

Here's the answer that worked for me:

<delete includeemptydirs="true">
    <fileset dir="${root}" defaultexcludes="false">
       <include name="**/*tmp*/**" />
    </fileset>
</delete>

我有一个更加复杂,我需要删除的.svn 目录了。随着 defaultexcludes 。* 被排除的文件,所以空目录是不是真的空的,所以间没有T得到清除。

I had an added complication I needed to remove .svn directories too. With defaultexcludes, .* files were being excluded, and so the empty directories weren't really empty, and so weren't getting removed.

属性 includeemptydirs (感谢,flicken,XL-Plüschhase)使尾部 ** 通配符匹配一个空字符串。

The attribute includeemptydirs (thanks, flicken, XL-Plüschhase) enables the trailing ** wildcard to match the an empty string.

这篇关于如何删除使用Ant目录的dirset?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆