1 | <!--
|
---|
2 | Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | contributor license agreements. See the NOTICE file distributed with
|
---|
4 | this work for additional information regarding copyright ownership.
|
---|
5 | The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | (the "License"); you may not use this file except in compliance with
|
---|
7 | the License. You may obtain a copy of the License at
|
---|
8 |
|
---|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 |
|
---|
11 | Unless required by applicable law or agreed to in writing, software
|
---|
12 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | See the License for the specific language governing permissions and
|
---|
15 | limitations under the License.
|
---|
16 | -->
|
---|
17 | <html>
|
---|
18 |
|
---|
19 | <head>
|
---|
20 | <meta http-equiv="Content-Language" content="en-us">
|
---|
21 | <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
---|
22 | <title>Fail Task</title>
|
---|
23 | </head>
|
---|
24 |
|
---|
25 | <body>
|
---|
26 |
|
---|
27 | <h2><a name="fail">Fail</a></h2>
|
---|
28 | <h3>Description</h3>
|
---|
29 | <p>Exits the current build (just throwing a BuildException), optionally printing additional information.</p>
|
---|
30 | <p>The message of the Exception can be set via the message attribute
|
---|
31 | or character data nested into the element.</p>
|
---|
32 | <h3>Parameters</h3>
|
---|
33 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
34 | <tr>
|
---|
35 | <td valign="top"><b>Attribute</b></td>
|
---|
36 | <td valign="top"><b>Description</b></td>
|
---|
37 | <td align="center" valign="top"><b>Required</b></td>
|
---|
38 | </tr>
|
---|
39 | <tr>
|
---|
40 | <td valign="top">message</td>
|
---|
41 | <td valign="top">A message giving further information on why the build exited</td>
|
---|
42 | <td align="center" valign="top">No</td>
|
---|
43 | </tr>
|
---|
44 | <tr>
|
---|
45 | <td valign="top">if</td>
|
---|
46 | <td valign="top">Only fail if a property of the given name exists
|
---|
47 | in the current project</td>
|
---|
48 | <td align="center" valign="top">No</td>
|
---|
49 | </tr>
|
---|
50 | <tr>
|
---|
51 | <td valign="top">unless</td>
|
---|
52 | <td valign="top">Only fail if a property of the given name doesn't
|
---|
53 | exist in the current project</td>
|
---|
54 | <td align="center" valign="top">No</td>
|
---|
55 | </tr>
|
---|
56 | <tr>
|
---|
57 | <td valign="top">status</td>
|
---|
58 | <td valign="top">Exit using the specified status code;
|
---|
59 | assuming the generated Exception is not caught, the
|
---|
60 | JVM will exit with this status. <em>Since Ant 1.6.2</em></td>
|
---|
61 | <td align="center" valign="top">No</td>
|
---|
62 | </tr>
|
---|
63 | </table>
|
---|
64 |
|
---|
65 | <h3>Parameters specified as nested elements</h3>
|
---|
66 |
|
---|
67 | <p>As an alternative to the <i>if</i>/<i>unless</i> attributes,
|
---|
68 | conditional failure can be achieved using a single nested
|
---|
69 | <code><condition></code> element, which should contain exactly one
|
---|
70 | core or custom condition. For information about conditions, see
|
---|
71 | <a href="conditions.html">here</a>.<br><b>Since Ant 1.6.2</b>
|
---|
72 | </p>
|
---|
73 |
|
---|
74 | <h3>Examples</h3>
|
---|
75 | <pre> <fail/></pre>
|
---|
76 | <p>will exit the current build with no further information given.</p>
|
---|
77 | <pre>
|
---|
78 | BUILD FAILED
|
---|
79 |
|
---|
80 | build.xml:4: No message
|
---|
81 | </pre>
|
---|
82 |
|
---|
83 | <pre> <fail message="Something wrong here."/></pre>
|
---|
84 | <p>will exit the current build and print something
|
---|
85 | like the following to wherever your output goes:
|
---|
86 | </p>
|
---|
87 | <pre>
|
---|
88 | BUILD FAILED
|
---|
89 |
|
---|
90 | build.xml:4: Something wrong here.
|
---|
91 | </pre>
|
---|
92 |
|
---|
93 | <pre> <fail>Something wrong here.</fail></pre>
|
---|
94 | <p>will give the same result as above.</p>
|
---|
95 |
|
---|
96 | <pre> <fail unless="thisdoesnotexist"/></pre>
|
---|
97 | <p>will exit the current build and print something
|
---|
98 | like the following to wherever your output goes:
|
---|
99 | </p>
|
---|
100 | <pre>
|
---|
101 | BUILD FAILED
|
---|
102 |
|
---|
103 | build.xml:2: unless=thisdoesnotexist
|
---|
104 | </pre>
|
---|
105 |
|
---|
106 | Using a condition to achieve the same effect:
|
---|
107 |
|
---|
108 | <pre>
|
---|
109 | <fail>
|
---|
110 | <condition>
|
---|
111 | <not>
|
---|
112 | <isset property="thisdoesnotexist"/>
|
---|
113 | </not>
|
---|
114 | </condition>
|
---|
115 | </fail>
|
---|
116 | </pre>
|
---|
117 |
|
---|
118 | <p>Output:</p>
|
---|
119 | <pre>
|
---|
120 | BUILD FAILED
|
---|
121 |
|
---|
122 | build.xml:2: condition satisfied
|
---|
123 | </pre>
|
---|
124 |
|
---|
125 |
|
---|
126 |
|
---|
127 | </body>
|
---|
128 | </html>
|
---|
129 |
|
---|