java left logo
java middle logo
java right logo
 

Home arrow Other API Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4096
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use Fail task E-mail
User Rating: / 2
PoorBest 

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
status Exit using the specified status code; assuming the generated Exception is not caught, the JVM will exit with this status. Since Ant 1.6.2 No

Parameters specified as nested elements

As an alternative to the if/unless attributes, conditional failure can be achieved using a single nested <condition> element, which should contain exactly one core or custom condition.

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
Using a condition to achieve the same effect:
  <fail>
     <condition>
       <not>
         <isset property="thisdoesnotexist"/>

       </not>
     </condition>
   </fail>

Output:

BUILD FAILED

build.xml:2: condition satisfied

Source: Apache Ant


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.