2006-09-11 04:19:00 +00:00
|
|
|
<!--
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
2001-02-13 12:32:01 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Language" content="en-us">
|
2005-04-29 18:58:16 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
2002-02-03 22:00:42 +00:00
|
|
|
<title>Fail Task</title>
|
2001-02-13 12:32:01 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2018-01-22 23:52:21 +01:00
|
|
|
<h2 id="fail">Fail</h2>
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Description</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Exits the current build (just throwing a BuildException), optionally printing additional
|
|
|
|
information.</p>
|
|
|
|
<p>The message of the Exception can be set via the message attribute or character data nested into
|
|
|
|
the element.</p>
|
2007-03-14 14:13:36 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Parameters</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2001-02-13 12:32:01 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>message</td>
|
|
|
|
<td>A message giving further information on why the build exited</td>
|
|
|
|
<td>No</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
2001-12-12 08:48:42 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>if</td>
|
|
|
|
<td>Only fail <a href="../properties.html#if+unless">if a property of the given name exists</a>
|
2001-12-12 08:48:42 +00:00
|
|
|
in the current project</td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>No</td>
|
2001-12-12 08:48:42 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>unless</td>
|
|
|
|
<td>Only fail <a href="../properties.html#if+unless">if a property of the given name doesn't
|
2009-11-05 00:45:05 +00:00
|
|
|
exist</a> in the current project</td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>No</td>
|
2001-12-12 08:48:42 +00:00
|
|
|
</tr>
|
2004-06-17 20:33:13 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>status</td>
|
|
|
|
<td>Exit using the specified status code; assuming the generated Exception is not caught, the
|
2010-11-11 17:04:16 +00:00
|
|
|
JVM will exit with this status. <em>Since Apache Ant 1.6.2</em></td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>No</td>
|
2004-06-17 20:33:13 +00:00
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
</table>
|
2004-04-28 18:08:47 +00:00
|
|
|
|
|
|
|
<h3>Parameters specified as nested elements</h3>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>As an alternative to the <var>if</var>/<var>unless</var> attributes, conditional failure can be
|
|
|
|
achieved using a single nested <code><condition></code> element, which should contain exactly
|
|
|
|
one core or custom condition. For information about conditions,
|
2018-03-02 08:23:45 +01:00
|
|
|
see <a href="conditions.html">here</a>.<br/><em>Since Ant 1.6.2</em>
|
2004-04-28 18:08:47 +00:00
|
|
|
</p>
|
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Examples</h3>
|
2007-03-14 14:13:36 +00:00
|
|
|
|
2018-05-15 09:51:58 +02:00
|
|
|
<p>Exit the current build with no further information given.</p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<pre><fail/></pre>
|
2018-05-15 09:51:58 +02:00
|
|
|
|
2018-03-10 20:17:33 +01:00
|
|
|
<pre class="output">
|
2001-02-13 12:32:01 +00:00
|
|
|
BUILD FAILED
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
build.xml:4: No message</pre>
|
2001-02-13 12:32:01 +00:00
|
|
|
|
2018-05-15 09:51:58 +02:00
|
|
|
<p>Exit the current build and print a message to wherever your output goes:</p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<pre><fail message="Something wrong here."/></pre>
|
2018-05-15 09:51:58 +02:00
|
|
|
|
2018-03-10 20:17:33 +01:00
|
|
|
<pre class="output">
|
2001-02-13 12:32:01 +00:00
|
|
|
BUILD FAILED
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
build.xml:4: Something wrong here.</pre>
|
2001-02-13 12:32:01 +00:00
|
|
|
|
2018-05-15 09:51:58 +02:00
|
|
|
<p>A different way to achieve the same result as above.</p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<pre><fail>Something wrong here.</fail></pre>
|
2001-03-29 10:21:12 +00:00
|
|
|
|
2018-05-15 09:51:58 +02:00
|
|
|
<p>Exit the current build and print an explanation to wherever your output goes:</p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<pre><fail unless="thisdoesnotexist"/></pre>
|
2018-05-15 09:51:58 +02:00
|
|
|
|
2018-03-10 20:17:33 +01:00
|
|
|
<pre class="output">
|
2004-04-28 18:08:47 +00:00
|
|
|
BUILD FAILED
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
build.xml:2: unless=thisdoesnotexist</pre>
|
2004-04-28 18:08:47 +00:00
|
|
|
|
2018-05-15 09:51:58 +02:00
|
|
|
<p>Use a condition to achieve the same effect:</p>
|
2004-04-28 18:08:47 +00:00
|
|
|
<pre>
|
2018-02-28 07:58:59 +01:00
|
|
|
<fail>
|
|
|
|
<condition>
|
|
|
|
<not>
|
|
|
|
<isset property="thisdoesnotexist"/>
|
|
|
|
</not>
|
|
|
|
</condition>
|
|
|
|
</fail></pre>
|
2004-04-28 18:08:47 +00:00
|
|
|
|
2018-03-10 20:17:33 +01:00
|
|
|
<pre class="output">
|
2004-04-28 18:08:47 +00:00
|
|
|
BUILD FAILED
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
build.xml:2: condition satisfied</pre>
|
2004-04-28 18:08:47 +00:00
|
|
|
|
2018-05-15 09:51:58 +02:00
|
|
|
<p>Check that both files <samp>one.txt</samp> and <samp>two.txt</samp> are present otherwise the
|
|
|
|
build will fail.</p>
|
2007-03-14 14:13:36 +00:00
|
|
|
<pre>
|
|
|
|
<fail message="Files are missing.">
|
|
|
|
<condition>
|
|
|
|
<not>
|
|
|
|
<resourcecount count="2">
|
|
|
|
<fileset id="fs" dir="." includes="one.txt,two.txt"/>
|
|
|
|
</resourcecount>
|
|
|
|
</not>
|
|
|
|
</condition>
|
2018-02-28 07:58:59 +01:00
|
|
|
</fail></pre>
|
2001-02-13 12:32:01 +00:00
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|