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

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