source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/docs/manual/CoreTasks/fail.html@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

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