检查多个文件存在与否使用ANT [英] Check multiple file exists or not using ANT

查看:226
本文介绍了检查多个文件存在与否使用ANT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ANT检查组文件计数两罐。
我不能够检查模式相同的文件是否存在。

I am using ANT to check count for set of files in two jars. I am not able to check whether the files of same pattern exists or not.

有关如我有2个文件,如/host/user/dir1/ABC1.txt和/host/user/dir1/ABC2.txt。

for e.g. I have 2 files like /host/user/dir1/ABC1.txt and /host/user/dir1/ABC2.txt.

现在我想检查是否图案的文件/主机/用户/ DIR1 / ABC *present与否?

now i want to check whether the file of pattern "/host/user/dir1/ABC*" present or not ??

我可以检查单个文件/host/user/dir1/ABC1.txt,利用现有的标记,但不能检查文件的特定模式。

I can check individual file /host/user/dir1/ABC1.txt, using available tag, but not able to check the files for specific pattern.

先谢谢了。

有关单个文件,以下工作正常:

For individual file, following works fine:

<if>
    <available file="${client.classes.src.dir}/${class_to_be_search}.class"/>
    <then>
         <echo> File ${client.classes.src.dir}/${class_to_be_search}.class FOUND in src dir 

         </echo>
         <echo> Update property client.jar.packages.listOfInnerClass</echo>
    </then>
    <else>
         <echo> File ${client.classes.src.dir}/${class_to_be_search}.class NOT FOUND      in src dir.  
         </echo>
    </else>
</if>

但我想搜索多个文件:
是这样的:$ {dir.structure} / $ {class_to_be_search} $ *类

But i want to search for multiple files: something like : ${dir.structure}/${class_to_be_search}$*.class

推荐答案

借助如果任务是不是核心ANT的一部分。

The if task is not part of core ANT.

下面的示例演示如何可以使用ANT 条件任务完成。您可以使用您在文件集想要的任何图案。目标执行随后就如何file.found属性已设置条件:

The following example shows how it can be done using the ANT condition task. You can use whatever pattern you want in the fileset. The target execution is subsequently conditional on how the "file.found" property has been set:

<project name="demo" default="run">

    <fileset id="classfiles" dir="build" includes="**/*.class"/>

    <condition property="file.found">
        <resourcecount refid="classfiles" when="greater" count="0"/>
    </condition>

    <target name="run" depends="found,notfound"/>

    <target name="found" if="file.found">
        <echo message="file found"/>
    </target>

    <target name="notfound" unless="file.found">
        <echo message="file not found"/>
    </target>

</project>

这篇关于检查多个文件存在与否使用ANT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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