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.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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><a name="fail">Fail</a></h2>
  23. <h3>Description</h3>
  24. <p>Exits the current build (just throwing a BuildException), optionally printing additional information.</p>
  25. <p>The message of the Exception can be set via the message attribute
  26. or character data nested into the element.</p>
  27. <h3>Parameters</h3>
  28. <table border="1" cellpadding="2" cellspacing="0">
  29. <tr>
  30. <td valign="top"><b>Attribute</b></td>
  31. <td valign="top"><b>Description</b></td>
  32. <td align="center" valign="top"><b>Required</b></td>
  33. </tr>
  34. <tr>
  35. <td valign="top">message</td>
  36. <td valign="top">A message giving further information on why the build exited</td>
  37. <td align="center" valign="top">No</td>
  38. </tr>
  39. <tr>
  40. <td valign="top">if</td>
  41. <td valign="top">Only fail <a href="../properties.html#if+unless">if a property of the given name exists</a>
  42. in the current project</td>
  43. <td align="center" valign="top">No</td>
  44. </tr>
  45. <tr>
  46. <td valign="top">unless</td>
  47. <td valign="top">Only fail <a href="../properties.html#if+unless">if a property of the given name doesn't
  48. exist</a> in the current project</td>
  49. <td align="center" valign="top">No</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">status</td>
  53. <td valign="top">Exit using the specified status code;
  54. assuming the generated Exception is not caught, the
  55. JVM will exit with this status. <em>Since Ant 1.6.2</em></td>
  56. <td align="center" valign="top">No</td>
  57. </tr>
  58. </table>
  59. <h3>Parameters specified as nested elements</h3>
  60. <p>As an alternative to the <i>if</i>/<i>unless</i> attributes,
  61. conditional failure can be achieved using a single nested
  62. <code>&lt;condition&gt;</code> element, which should contain exactly one
  63. core or custom condition. For information about conditions, see
  64. <a href="conditions.html">here</a>.<br><b>Since Ant 1.6.2</b>
  65. </p>
  66. <h3>Examples</h3>
  67. <pre> &lt;fail/&gt;</pre>
  68. <p>will exit the current build with no further information given.</p>
  69. <pre>
  70. BUILD FAILED
  71. build.xml:4: No message
  72. </pre>
  73. <pre> &lt;fail message=&quot;Something wrong here.&quot;/&gt;</pre>
  74. <p>will exit the current build and print something
  75. like the following to wherever your output goes:
  76. </p>
  77. <pre>
  78. BUILD FAILED
  79. build.xml:4: Something wrong here.
  80. </pre>
  81. <pre> &lt;fail&gt;Something wrong here.&lt;/fail&gt;</pre>
  82. <p>will give the same result as above.</p>
  83. <pre> &lt;fail unless=&quot;thisdoesnotexist&quot;/&gt;</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. build.xml:2: unless=thisdoesnotexist
  90. </pre>
  91. Using a condition to achieve the same effect:
  92. <pre>
  93. &lt;fail&gt;
  94. &lt;condition&gt;
  95. &lt;not&gt;
  96. &lt;isset property=&quot;thisdoesnotexist&quot;/&gt;
  97. &lt;/not&gt;
  98. &lt;/condition&gt;
  99. &lt;/fail&gt;
  100. </pre>
  101. <p>Output:</p>
  102. <pre>
  103. BUILD FAILED
  104. build.xml:2: condition satisfied
  105. </pre>
  106. <pre>
  107. &lt;fail message=&quot;Files are missing.&quot;&gt;
  108. &lt;condition&gt;
  109. &lt;not&gt;
  110. &lt;resourcecount count=&quot;2&quot;&gt;
  111. &lt;fileset id=&quot;fs&quot; dir=&quot;.&quot; includes=&quot;one.txt,two.txt&quot;/&gt;
  112. &lt;/resourcecount&gt;
  113. &lt;/not&gt;
  114. &lt;/condition&gt;
  115. &lt;/fail&gt;
  116. </pre>
  117. <p>Will check that both files <i>one.txt</i> and <i>two.txt</i> are present otherwise the build
  118. will fail.</p>
  119. </body>
  120. </html>