递归使用Ant删除一个类型的所有文件 [英] Recursively deleting all files of one type using Ant

查看:219
本文介绍了递归使用Ant删除一个类型的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Ant构建脚本,我怎么能删除一个目录及其子目录中的所有 *。java的文件?

In an ant build script, how can I delete all *.java files in one directory and its subdirectory?

推荐答案

这是稍微不清楚,你想有多深目录树中删除的.java 文件。我会提供一些​​方法一举两得。

It's slightly unclear how deep in the directory tree you would like to delete the .java files. I'll provide ways to do both.

展开递归删除

递归删除所有的.java 提供的目标目录下的任何地方的文件。

Recursively deletes all .java files anywhere under the provided target directory.

<delete>
    <fileset dir="${basedir}/path/to/target/directory" includes="**/*.java"/>
</delete>

仅在目标目录及其直接子目录

删除的.java 文件,在作为目标目录的直接子的任何目录,但

Deletes .java files in the specified target directory, and in any directories that are immediate children of the target directory, but no further.

<delete>
    <fileset dir="${basedir}/path/to/target/directory" includes="*.java,*/*.java"/>
</delete>

有关其他选项,看看对于删除任务文档

For additional options, have a look at the documentation for the delete task.

注意 - 如果你把错误的目录为目标目录,你可以删除你不想要的东西。考虑使得路径目标相对于生成文件目录,或 $ {BASEDIR}

Be careful - If you put the wrong directory in for your target directory, you might delete things you don't want to. Consider making the paths to your target dir relative to the build file, or to ${basedir}.

这篇关于递归使用Ant删除一个类型的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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