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.

input.html 7.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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>Input Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="input">Input</a></h2>
  23. <h3>Description</h3>
  24. <p>Allows user interaction during the build process by prompting for
  25. input. To do so, it uses the configured
  26. <a href="../inputhandler.html">InputHandler</a>.</p>
  27. <p>The prompt can be set via the message attribute or as character
  28. data nested into the element.</p>
  29. <p>Optionally a set of valid input arguments can be defined via the
  30. validargs attribute. Input task will not accept a value that doesn't match
  31. one of the predefined.</p>
  32. <p>Optionally a property can be created from the value entered by the
  33. user. This property can then be used during the following build
  34. run. Input behaves according to <a href="property.html">property
  35. task</a> which means that existing properties cannot be overriden.
  36. Since Ant 1.6, <code>&lt;input&gt;</code> will not prompt for input if
  37. a property should be set by the task that has already been set in the
  38. project (and the task wouldn't have any effect).</p>
  39. <p>Historically, a regular complaint about this task has been that it echoes
  40. characters to the console, this is a critical security defect, we must fix it
  41. immediately, etc, etc. This problem was due to the lack in early versions of
  42. Java of a (fully functional) facility for handling secure console input.
  43. In Java 1.6 that shortcoming in Java's API was addressed and Ant versions 1.7.1
  44. and 1.8 have added support for Java 1.6's secure console input feature
  45. (see <a href="#handler.type">handler type</a>).</p>
  46. <p>
  47. IDE behaviour depends upon the IDE: some hang waiting for input, some let you
  48. type it in. For this situation, place the password in a (secured) property
  49. file and load in before the input task.</p>
  50. <h3>Parameters</h3>
  51. <table border="1" cellpadding="2" cellspacing="0">
  52. <tr>
  53. <td valign="top"><b>Attribute</b></td>
  54. <td valign="top"><b>Description</b></td>
  55. <td align="center" valign="top"><b>Required</b></td>
  56. </tr>
  57. <tr>
  58. <td valign="top">message</td>
  59. <td valign="top">the Message which gets displayed to the user
  60. during the build run.</td>
  61. <td valign="top" align="center">No</td>
  62. </tr>
  63. <tr>
  64. <td valign="top">validargs</td>
  65. <td valign="top">comma separated String containing valid input
  66. arguments. If set, input task will reject any input not defined
  67. here. Validargs are compared case sensitive. If you want 'a' and
  68. 'A' to be accepted you will need to define both arguments within
  69. validargs.</td>
  70. <td valign="top" align="center">No</td>
  71. </tr>
  72. <tr>
  73. <td valign="top">addproperty</td>
  74. <td valign="top">the name of a property to be created from
  75. input. Behaviour is equal to <a href="property.html">property
  76. task</a> which means that existing properties cannot be
  77. overridden.</td>
  78. <td valign="top" align="center">No</td>
  79. </tr>
  80. <tr>
  81. <td valign="top">defaultvalue</td>
  82. <td valign="top">Defines the default value of the property to be
  83. created from input. Property value will be set to default if no
  84. input is received.</td>
  85. <td valign="top" align="center">No</td>
  86. </tr>
  87. </table>
  88. <h3>Parameters Specified as Nested Elements</h3>
  89. <h4>Handler</h4>
  90. <p>Since <b>Ant 1.7</b>, a nested &lt;handler&gt; element can be used to
  91. specify an InputHandler, so that different InputHandlers may be used
  92. among different Input tasks.
  93. <table border="1" cellpadding="2" cellspacing="0">
  94. <tr>
  95. <td valign="top"><b>Attribute</b></td>
  96. <td valign="top"><b>Description</b></td>
  97. <td align="center" valign="top"><b>Required</b></td>
  98. </tr>
  99. <tr>
  100. <td valign="top"><a name="handler.type" />type</td>
  101. <td valign="top">one of "default","propertyfile", "greedy", or "secure" (since Ant 1.8).
  102. </td>
  103. <td align="center" valign="top" rowspan="3">One of these</td>
  104. </tr>
  105. <tr>
  106. <td valign="top">refid</td>
  107. <td valign="top">Reference to an <code>InputHandler</code>
  108. defined elsewhere in the project.
  109. </td>
  110. </tr>
  111. <tr>
  112. <td valign="top">classname</td>
  113. <td valign="top">The name of an <code>InputHandler</code> subclass.</td>
  114. </tr>
  115. <tr>
  116. <td valign="top">classpath</td>
  117. <td valign="top">The classpath to use with <i>classname</i>.</td>
  118. <td valign="top">No</td>
  119. </tr>
  120. <tr>
  121. <td valign="top">classpathref</td>
  122. <td valign="top">The refid of a classpath to use with <i>classname</i>.</td>
  123. <td valign="top">No</td>
  124. </tr>
  125. <tr>
  126. <td valign="top">loaderref</td>
  127. <td valign="top">The refid of a classloader to use with <i>classname</i>.
  128. </td>
  129. <td valign="top">No</td>
  130. </tr>
  131. </table>
  132. <br />
  133. The classpath can also be specified by means of one or more nested
  134. &lt;classpath&gt; elements.</p>
  135. <h3>Examples</h3>
  136. <pre> &lt;input/&gt;</pre>
  137. <p>Will pause the build run until return key is pressed when using the
  138. <a href="../inputhandler.html#defaulthandler">default
  139. InputHandler</a>, the concrete behavior is defined by the InputHandler
  140. implementation you use.</p>
  141. <pre> &lt;input&gt;Press Return key to continue...&lt;/input&gt;</pre>
  142. <p>Will display the message &quot;Press Return key to
  143. continue...&quot; and pause the build run until return key is pressed
  144. (again, the concrete behavior is implementation dependent).</p>
  145. <pre> &lt;input
  146. message=&quot;Press Return key to continue...&quot;
  147. /&gt;</pre>
  148. <p>Will display the message &quot;Press Return key to
  149. continue...&quot; and pause the build run until return key is pressed
  150. (see above).</p>
  151. <pre>
  152. &lt;input
  153. message=&quot;All data is going to be deleted from DB continue (y/n)?&quot;
  154. validargs=&quot;y,n&quot;
  155. addproperty=&quot;do.delete&quot;
  156. /&gt;
  157. &lt;condition property=&quot;do.abort&quot;&gt;
  158. &lt;equals arg1=&quot;n&quot; arg2=&quot;${do.delete}&quot;/&gt;
  159. &lt;/condition&gt;
  160. &lt;fail if=&quot;do.abort&quot;&gt;Build aborted by user.&lt;/fail&gt;
  161. </pre>
  162. <p>Will display the message &quot;All data is going to be deleted from
  163. DB continue (y/n)?&quot; and require 'y' to continue build or 'n' to
  164. exit build with following message &quot;Build aborted by
  165. user.&quot;.</p>
  166. <pre> &lt;input
  167. message=&quot;Please enter db-username:&quot;
  168. addproperty=&quot;db.user&quot;
  169. /&gt;</pre>
  170. <p>Will display the message &quot;Please enter db-username:&quot; and set the
  171. property <code>db.user</code> to the value entered by the user.</p>
  172. <pre> &lt;input
  173. message=&quot;Please enter db-username:&quot;
  174. addproperty=&quot;db.user&quot;
  175. defaultvalue=&quot;Scott-Tiger&quot;
  176. /&gt;</pre>
  177. <p>Same as above, but will set <code>db.user</code> to the value
  178. <i>Scott- Tiger</i> if the user enters no value (simply types
  179. &lt;return&gt;).</p>
  180. </body>
  181. </html>