Apache Ant Fail Task

This task is used to stop current build and throw BuildException. It exits from the current build and displays an exception message to the console.

The message attribute is used to set exception message to this element.

Apache Ant Fail Task Attributes

AttributeDescriptionRequired
messageA message to show the reason of fail.No
ifOnly fail if a property exists in current directory.No
unlessOnly fail if a property doesn't exist in the current projectNo

Lets see some examples of Ant Fail Task which are given below.

Apache Ant Fail Task Example

Without message

Set message too

Using unless

Output:

fail:
BUILD FAILED
unless=it is unless message




Latest Courses