如何检查文件是否存在,如果没有杀死构建?

Ste*_*eve 14 ant

如何停止构建,并在文件不存在时通知用户?我知道如果文件存在,我可以使用可用的任务来设置属性,但我不确定如何停止构建并回显一些东西.

如果可能的话,我想坚持核心任务.

sti*_*mms 19

您可以将失败任务用于满足所有失败需求.该页面上的最后一个示例实际上就是您所需要的

<fail message="Files are missing.">
    <condition>
        <not>
            <resourcecount count="2">
                <fileset id="fs" dir="." includes="one.txt,two.txt"/>
            </resourcecount>
        </not>
    </condition>
</fail>
Run Code Online (Sandbox Code Playgroud)


leo*_*loy 16

更简单一点(我希望它可以变得更简单)

<fail message="file ${myfile} not set or missing">
    <condition>
        <not>
            <available file="${myfile}" />
        </not>
    </condition>
</fail>
Run Code Online (Sandbox Code Playgroud)


Jas*_*yon 6

设置属性并使用if属性的Fail任务.