Fail

Description

Exits the current build (just throwing a BuildException), optionally printing additional information.

The message of the Exception can be set via the message attribute or character data nested into the element.

Parameters

Attribute Description Required
message A message giving further information on why the build exited No
if Only fail if a property of the given name exists in the current project No
unless Only fail if a property of the given name doesn't exist in the current project No

Parameters specified as nested elements

As an alternative to the if/unless attributes, conditional failure can be achieved using a single nested condition. For a complete list of core conditions, as well as information about custom conditions, see here.
Since Ant 1.6.2

Examples

  <fail/>

will exit the current build with no further information given.

BUILD FAILED

build.xml:4: No message
  <fail message="Something wrong here."/>

will exit the current build and print something like the following to wherever your output goes:

BUILD FAILED

build.xml:4: Something wrong here.
  <fail>Something wrong here.</fail>

will give the same result as above.

  <fail unless="thisdoesnotexist"/>

will exit the current build and print something like the following to wherever your output goes:

BUILD FAILED

build.xml:2: unless=thisdoesnotexist
A simple example using conditions to achieve the same effect:
  <fail>
     <not>
       <isset property="thisdoesnotexist"/>
     </not>
   </fail>

Output:

BUILD FAILED

build.xml:2: condition satisfied

Copyright © 2000-2001,2004 The Apache Software Foundation. All rights Reserved.