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 3.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  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>Attribute</th>
  32. <th>Description</th>
  33. <th>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. <pre>&lt;fail/&gt;</pre>
  67. <p>will exit the current build with no further information given.</p>
  68. <pre>
  69. BUILD FAILED
  70. build.xml:4: No message</pre>
  71. <pre>&lt;fail message=&quot;Something wrong here.&quot;/&gt;</pre>
  72. <p>will exit the current build and print something like the following to wherever your output
  73. goes:</p>
  74. <pre>
  75. BUILD FAILED
  76. build.xml:4: Something wrong here.</pre>
  77. <pre>&lt;fail&gt;Something wrong here.&lt;/fail&gt;</pre>
  78. <p>will give the same result as above.</p>
  79. <pre>&lt;fail unless=&quot;thisdoesnotexist&quot;/&gt;</pre>
  80. <p>will exit the current build and print something like the following to wherever your output
  81. goes:</p>
  82. <pre>
  83. BUILD FAILED
  84. build.xml:2: unless=thisdoesnotexist</pre>
  85. Using a condition to achieve the same effect:
  86. <pre>
  87. &lt;fail&gt;
  88. &lt;condition&gt;
  89. &lt;not&gt;
  90. &lt;isset property=&quot;thisdoesnotexist&quot;/&gt;
  91. &lt;/not&gt;
  92. &lt;/condition&gt;
  93. &lt;/fail&gt;</pre>
  94. <p>Output:</p>
  95. <pre>
  96. BUILD FAILED
  97. build.xml:2: condition satisfied</pre>
  98. <pre>
  99. &lt;fail message=&quot;Files are missing.&quot;&gt;
  100. &lt;condition&gt;
  101. &lt;not&gt;
  102. &lt;resourcecount count=&quot;2&quot;&gt;
  103. &lt;fileset id=&quot;fs&quot; dir=&quot;.&quot; includes=&quot;one.txt,two.txt&quot;/&gt;
  104. &lt;/resourcecount&gt;
  105. &lt;/not&gt;
  106. &lt;/condition&gt;
  107. &lt;/fail&gt;</pre>
  108. <p>Will check that both files <samp>one.txt</samp> and <samp>two.txt</samp> are present otherwise
  109. the build will fail.</p>
  110. </body>
  111. </html>