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

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