You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

fail.html 4.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Fail Task</title>
  20. </head>
  21. <body>
  22. <h2 id="fail">Fail</h2>
  23. <h3>Description</h3>
  24. <p>Exits the current build (just throwing a BuildException), optionally printing additional
  25. information.</p>
  26. <p>The message of the Exception can be set via the message attribute or character data nested into
  27. the element.</p>
  28. <h3>Parameters</h3>
  29. <table class="attr">
  30. <tr>
  31. <th scope="col">Attribute</th>
  32. <th scope="col">Description</th>
  33. <th scope="col">Required</th>
  34. </tr>
  35. <tr>
  36. <td>message</td>
  37. <td>A message giving further information on why the build exited</td>
  38. <td>No</td>
  39. </tr>
  40. <tr>
  41. <td>if</td>
  42. <td>Only fail <a href="../properties.html#if+unless">if a property of the given name exists</a>
  43. in the current project</td>
  44. <td>No</td>
  45. </tr>
  46. <tr>
  47. <td>unless</td>
  48. <td>Only fail <a href="../properties.html#if+unless">if a property of the given name doesn't
  49. exist</a> in the current project</td>
  50. <td>No</td>
  51. </tr>
  52. <tr>
  53. <td>status</td>
  54. <td>Exit using the specified status code; assuming the generated Exception is not caught, the
  55. JVM will exit with this status. <em>Since Apache Ant 1.6.2</em></td>
  56. <td>No</td>
  57. </tr>
  58. </table>
  59. <h3>Parameters specified as nested elements</h3>
  60. <p>As an alternative to the <var>if</var>/<var>unless</var> attributes, conditional failure can be
  61. achieved using a single nested <code>&lt;condition&gt;</code> element, which should contain exactly
  62. one core or custom condition. For information about conditions,
  63. see <a href="conditions.html">here</a>.<br/><em>Since Ant 1.6.2</em>
  64. </p>
  65. <h3>Examples</h3>
  66. <p>Exit the current build with no further information given.</p>
  67. <pre>&lt;fail/&gt;</pre>
  68. <pre class="output">
  69. BUILD FAILED
  70. build.xml:4: No message</pre>
  71. <p>Exit the current build and print a message to wherever your output goes:</p>
  72. <pre>&lt;fail message=&quot;Something wrong here.&quot;/&gt;</pre>
  73. <pre class="output">
  74. BUILD FAILED
  75. build.xml:4: Something wrong here.</pre>
  76. <p>A different way to achieve the same result as above.</p>
  77. <pre>&lt;fail&gt;Something wrong here.&lt;/fail&gt;</pre>
  78. <p>Exit the current build and print an explanation to wherever your output goes:</p>
  79. <pre>&lt;fail unless=&quot;thisdoesnotexist&quot;/&gt;</pre>
  80. <pre class="output">
  81. BUILD FAILED
  82. build.xml:2: unless=thisdoesnotexist</pre>
  83. <p>Use a condition to achieve the same effect:</p>
  84. <pre>
  85. &lt;fail&gt;
  86. &lt;condition&gt;
  87. &lt;not&gt;
  88. &lt;isset property=&quot;thisdoesnotexist&quot;/&gt;
  89. &lt;/not&gt;
  90. &lt;/condition&gt;
  91. &lt;/fail&gt;</pre>
  92. <pre class="output">
  93. BUILD FAILED
  94. build.xml:2: condition satisfied</pre>
  95. <p>Check that both files <samp>one.txt</samp> and <samp>two.txt</samp> are present otherwise the
  96. build will fail.</p>
  97. <pre>
  98. &lt;fail message=&quot;Files are missing.&quot;&gt;
  99. &lt;condition&gt;
  100. &lt;not&gt;
  101. &lt;resourcecount count=&quot;2&quot;&gt;
  102. &lt;fileset id=&quot;fs&quot; dir=&quot;.&quot; includes=&quot;one.txt,two.txt&quot;/&gt;
  103. &lt;/resourcecount&gt;
  104. &lt;/not&gt;
  105. &lt;/condition&gt;
  106. &lt;/fail&gt;</pre>
  107. </body>
  108. </html>