Name

fail

Synopsis

Throws a BuildException, causing the current build to fail.

Attributes

message (all, String, N)

Specifies the message displayed when this task executes.

Content

Text content. (1.4)

Ant 1.4 adds the ability to specify nested text. This is useful when the message spans multiple lines.

Example Usage

The following example aborts the build without any descriptive message:

<fail/>

In this case, Ant displays the following message, where 104 is the line number in the buildfile of the line invoking fail:

BUILD FAILED
C:\cvsdata\ant\mysamples\build.xml:104: No message

The following call to fail results in a message being displayed. The message is specified between the <fail> and </fail> tags.

<fail>Java version ${java.version} is not allowed!</fail>

The next example produces the same results as the previous one; the only difference is that the message is specified using the message attribute.

<fail message="Java version ${java.version} is not allowed!"/>

See Also

Use the echo task to write messages without aborting the build.

Get Ant: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.