source: release-kits/lirk3/bin/ant-installer/web/manual1.6.2/manual/CoreTasks/fail.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 3.0 KB
Line 
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
15or 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 &lt;condition&gt; 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> &lt;fail/&gt;</pre>
60<p>will exit the current build with no further information given.</p>
61<pre>
62BUILD FAILED
63
64build.xml:4: No message
65</pre>
66
67<pre> &lt;fail message=&quot;Something wrong here.&quot;/&gt;</pre>
68<p>will exit the current build and print something
69 like the following to wherever your output goes:
70</p>
71<pre>
72BUILD FAILED
73
74build.xml:4: Something wrong here.
75</pre>
76
77<pre> &lt;fail&gt;Something wrong here.&lt;/fail&gt;</pre>
78<p>will give the same result as above.</p>
79
80<pre> &lt;fail unless=&quot;thisdoesnotexist&quot;/&gt;</pre>
81<p>will exit the current build and print something
82 like the following to wherever your output goes:
83</p>
84<pre>
85BUILD FAILED
86
87build.xml:2: unless=thisdoesnotexist
88</pre>
89
90Using a condition to achieve the same effect:
91
92<pre>
93 &lt;fail&gt;
94 &lt;condition&gt;
95 &lt;not&gt;
96 &lt;isset property=&quot;thisdoesnotexist&quot;/&gt;
97 &lt;/not&gt;
98 &lt;/condition&gt;
99 &lt;/fail&gt;
100</pre>
101
102<p>Output:</p>
103<pre>
104BUILD FAILED
105
106build.xml:2: condition satisfied
107</pre>
108
109<hr>
110<p align="center">Copyright &copy; 2000-2001,2004 The Apache Software Foundation. All rights
111Reserved.</p>
112
113</body>
114</html>
115
Note: See TracBrowser for help on using the repository browser.