如何测试 ANT 中的目录是否为空?
如何测试 ant 中的目录是否为空?
How can one test to see that a directory is empty in ant?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何测试 ant 中的目录是否为空?
How can one test to see that a directory is empty in ant?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
您可以使用
pathconvert
任务来执行此操作,带有setonempty
属性。仅当 refid 为
myfileset
的文件集不为空时,才会设置属性fileset.notempty
。您只需使用目录定义
myfileset
,并且没有排除会获得目录空测试:请参阅 此示例用于用例:
You can use the
pathconvert
task to do that, with thesetonempty
property.will set the property
fileset.notempty
only if the fileset those refid ismyfileset
is not empty.You just have to define
myfileset
with your directory, and no excludes do get a directory empty test:See this example for a use case:
这只是对tonio的答案的补充。
在此示例中,使用
git
命令模拟cvs checkout
:git clone
当dir
为空时git fetch
否则This is just a complement for tonio's answer.
In this example
cvs checkout
is emulated usinggit
commands:git clone
whendir
is emptygit fetch
else仅当目录为空时才设置属性的脚本化解决方案:
scripted solution that sets a property only when the directory is empty: