Apache ANT Tasks Tutorial
Selected Reading
- Ant Tasks - Discussion
- Ant Tasks - Useful Resources
- Ant Tasks - Quick Guide
- ANT Tasks -JAR
- ANT Tasks - Zip
- ANT Tasks - WAR
- ANT Tasks - Sleep
- ANT Tasks - Move
- ANT Tasks - MkDir
- ANT Tasks - LoadFile
- ANT Tasks - Length
- ANT Tasks - Javac
- ANT Tasks - Java
- ANT Tasks - Import
- ANT Tasks - Fail
- ANT Tasks - EAR
- ANT Tasks - Delete
- ANT Tasks - Copy
- ANT Tasks - Condition
- ANT Tasks - Concat
- ANT Tasks - Chmod
- ANT Tasks - GUnzip
- ANT Tasks - GZip
- ANT Tasks - BaseName
- ANT Tasks - Environment Setup
- ANT Tasks - Introduction
- ANT Tasks - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
ANT Tasks - Fail
Apache Ant Tasks - Fail
Description
Fail task is used to exit the current build by 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.
Properties
Sr.No | Attributes & Description |
---|---|
1 | Message A message giving further information on why the build exited. |
2 | If Only fail if a property of the given name exists in the current project |
3 | Unless Only fail if a property of the given name doesn t exist in the current project |
4 | Status Exit using the specified status code; assuming the generated Exception is not caught, the JVM will exit with this status. |
Example
Usage
Create build.xml with the following content −
<?xml version="1.0"?> <project name="TutorialPoint" default="info"> <property name="build.dir" value="build" /> <target name="info"> <fail unless="src.dir"/> </target> </project>
Above script will fail the build as src.dir is not set.
Output
Running Ant on the above build file produces the following output −
F: utorialspointant>ant Buildfile: F: utorialspointantuild.xml info: BUILD FAILED F: utorialspointantuild.xml:5: unless=src.dir Total time: 0 secondsAdvertisements