Ant:如果目录不存在,如何忽略构建错误?

Dav*_*ave 13 ant

我正在使用Ant 1.8.1.如果目录不存在,如何忽略以下构建错误?我得到的错误是

BUILD FAILED
/Users/davea/myco2-myco/build.xml:211: Directory does not exist: /Users/davea/myco2-myco/${mycousa.test.root}
Run Code Online (Sandbox Code Playgroud)

有问题的行是下面的子句中的delete指令.认为"erroronmissingdir"属性可以解决问题,但我猜不是......

    <delete>
            <fileset dir="${mycousa.test.root}" erroronmissingdir="false">
                    <include name="suite.html" />
            </fileset>
    </delete>
Run Code Online (Sandbox Code Playgroud)

让我知道如何修改上面的内容,以便即使目录不存在也不会收到错误.

谢谢 - 戴夫

Bre*_*ode 18

我认为问题是你正在处理的错误条件是创建FileSet,而不是删除本身.查看failonerror删除任务的指令:

<delete failonerror="false">
            <fileset dir="${mycousa.test.root}" erroronmissingdir="false">
                    <include name="suite.html" />
            </fileset>
</delete>
Run Code Online (Sandbox Code Playgroud)

参考:http://ant.apache.org/manual/Tasks/delete.html