[14982] | 1 | <html>
|
---|
| 2 |
|
---|
| 3 | <head>
|
---|
| 4 | <meta http-equiv="Content-Language" content="en-us">
|
---|
| 5 | <title>Fail Task</title>
|
---|
| 6 | <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
|
---|
| 7 | </head>
|
---|
| 8 |
|
---|
| 9 | <body>
|
---|
| 10 |
|
---|
| 11 | <h2><a name="fail">Fail</a></h2>
|
---|
| 12 | <h3>Description</h3>
|
---|
| 13 | <p>Exits the current build (just throwing a BuildException), optionally printing additional information.</p>
|
---|
| 14 | <p>The message of the Exception can be set via the message attribute
|
---|
| 15 | or character data nested into the element.</p>
|
---|
| 16 | <h3>Parameters</h3>
|
---|
| 17 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
| 18 | <tr>
|
---|
| 19 | <td valign="top"><b>Attribute</b></td>
|
---|
| 20 | <td valign="top"><b>Description</b></td>
|
---|
| 21 | <td align="center" valign="top"><b>Required</b></td>
|
---|
| 22 | </tr>
|
---|
| 23 | <tr>
|
---|
| 24 | <td valign="top">message</td>
|
---|
| 25 | <td valign="top">A message giving further information on why the build exited</td>
|
---|
| 26 | <td align="center" valign="top">No</td>
|
---|
| 27 | </tr>
|
---|
| 28 | <tr>
|
---|
| 29 | <td valign="top">if</td>
|
---|
| 30 | <td valign="top">Only fail if a property of the given name exists
|
---|
| 31 | in the current project</td>
|
---|
| 32 | <td align="center" valign="top">No</td>
|
---|
| 33 | </tr>
|
---|
| 34 | <tr>
|
---|
| 35 | <td valign="top">unless</td>
|
---|
| 36 | <td valign="top">Only fail if a property of the given name doesn't
|
---|
| 37 | exist in the current project</td>
|
---|
| 38 | <td align="center" valign="top">No</td>
|
---|
| 39 | </tr>
|
---|
| 40 | <tr>
|
---|
| 41 | <td valign="top">status</td>
|
---|
| 42 | <td valign="top">Exit using the specified status code;
|
---|
| 43 | assuming the generated Exception is not caught, the
|
---|
| 44 | JVM will exit with this status. <em>Since Ant 1.7</em></td>
|
---|
| 45 | <td align="center" valign="top">No</td>
|
---|
| 46 | </tr>
|
---|
| 47 | </table>
|
---|
| 48 |
|
---|
| 49 | <h3>Parameters specified as nested elements</h3>
|
---|
| 50 |
|
---|
| 51 | <p>As an alternative to the <i>if</i>/<i>unless</i> attributes,
|
---|
| 52 | conditional failure can be achieved using a single nested
|
---|
| 53 | <condition> element, which should contain exactly one
|
---|
| 54 | core or custom condition. For information about conditions, see
|
---|
| 55 | <a href="conditions.html">here</a>.<br /><b>Since Ant 1.6.2</b>
|
---|
| 56 | </p>
|
---|
| 57 |
|
---|
| 58 | <h3>Examples</h3>
|
---|
| 59 | <pre> <fail/></pre>
|
---|
| 60 | <p>will exit the current build with no further information given.</p>
|
---|
| 61 | <pre>
|
---|
| 62 | BUILD FAILED
|
---|
| 63 |
|
---|
| 64 | build.xml:4: No message
|
---|
| 65 | </pre>
|
---|
| 66 |
|
---|
| 67 | <pre> <fail message="Something wrong here."/></pre>
|
---|
| 68 | <p>will exit the current build and print something
|
---|
| 69 | like the following to wherever your output goes:
|
---|
| 70 | </p>
|
---|
| 71 | <pre>
|
---|
| 72 | BUILD FAILED
|
---|
| 73 |
|
---|
| 74 | build.xml:4: Something wrong here.
|
---|
| 75 | </pre>
|
---|
| 76 |
|
---|
| 77 | <pre> <fail>Something wrong here.</fail></pre>
|
---|
| 78 | <p>will give the same result as above.</p>
|
---|
| 79 |
|
---|
| 80 | <pre> <fail unless="thisdoesnotexist"/></pre>
|
---|
| 81 | <p>will exit the current build and print something
|
---|
| 82 | like the following to wherever your output goes:
|
---|
| 83 | </p>
|
---|
| 84 | <pre>
|
---|
| 85 | BUILD FAILED
|
---|
| 86 |
|
---|
| 87 | build.xml:2: unless=thisdoesnotexist
|
---|
| 88 | </pre>
|
---|
| 89 |
|
---|
| 90 | Using a condition to achieve the same effect:
|
---|
| 91 |
|
---|
| 92 | <pre>
|
---|
| 93 | <fail>
|
---|
| 94 | <condition>
|
---|
| 95 | <not>
|
---|
| 96 | <isset property="thisdoesnotexist"/>
|
---|
| 97 | </not>
|
---|
| 98 | </condition>
|
---|
| 99 | </fail>
|
---|
| 100 | </pre>
|
---|
| 101 |
|
---|
| 102 | <p>Output:</p>
|
---|
| 103 | <pre>
|
---|
| 104 | BUILD FAILED
|
---|
| 105 |
|
---|
| 106 | build.xml:2: condition satisfied
|
---|
| 107 | </pre>
|
---|
| 108 |
|
---|
| 109 | <hr>
|
---|
| 110 | <p align="center">Copyright © 2000-2001,2004 The Apache Software Foundation. All rights
|
---|
| 111 | Reserved.</p>
|
---|
| 112 |
|
---|
| 113 | </body>
|
---|
| 114 | </html>
|
---|
| 115 |
|
---|