gpt4 book ai didi

ant - 使用ANT检查多个文件是否存在

转载 作者:行者123 更新时间:2023-12-04 05:04:33 25 4
gpt4 key购买 nike

我正在使用 ANT 检查两个 jar 中文件集的计数。
我无法检查是否存在相同模式的文件。

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

现在我想检查模式文件“/host/user/dir1/ABC*”是否存在?

我可以使用可用标签检查单个文件/host/user/dir1/ABC1.txt,但无法检查特定模式的文件。

提前致谢。

对于单个文件,以下工作正常:

<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}$*.class

最佳答案

if task不是核心 ANT 的一部分。

以下示例显示了如何使用 ANT condition task 完成此操作。 .您可以在文件集中使用任何您想要的模式。目标执行随后取决于“file.found”属性的设置方式:

<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 - 使用ANT检查多个文件是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15698694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com