Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant: How can I ignore build error if directory doesn't exist?

Tags:

ant

I'm using Ant 1.8.1. How can I ignore the following build error if a directory doesn't exist? The error I get is

BUILD FAILED
/Users/davea/myco2-myco/build.xml:211: Directory does not exist: /Users/davea/myco2-myco/${mycousa.test.root}

The line in question is the delete directive from the clause below. Thought the "erroronmissingdir" attribute would have solved the problem, but I guess not …

    <delete>
            <fileset dir="${mycousa.test.root}" erroronmissingdir="false">
                    <include name="suite.html" />
            </fileset>
    </delete>

Let me know how I can modify the above so that I won't get the error even if the directory doesn't exist.

Thanks - Dave

like image 383
Dave Avatar asked Jun 17 '11 16:06

Dave


2 Answers

I think the problem is that the error condition you're handling is on the creation of the FileSet, not the delete itself. Check out the failonerror directive on the delete task:

<delete failonerror="false">
            <fileset dir="${mycousa.test.root}" erroronmissingdir="false">
                    <include name="suite.html" />
            </fileset>
</delete>

Reference: http://ant.apache.org/manual/Tasks/delete.html

like image 97
Brent Writes Code Avatar answered Nov 06 '22 10:11

Brent Writes Code


It's a bug in ant (version <= 1.8.0).

See

https://issues.apache.org/bugzilla/show_bug.cgi?id=50124

The fix:

http://svn.apache.org/viewvc?view=revision&revision=1027000

like image 33
BeeOnRope Avatar answered Nov 06 '22 11:11

BeeOnRope