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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Input Task</title>
  20. </head>
  21. <body>
  22. <h2 id="input">Input</h2>
  23. <h3>Description</h3>
  24. <p>Allows user interaction during the build process by prompting for input. To do so, it uses the
  25. configured <a href="../inputhandler.html">InputHandler</a>.</p>
  26. <p>The prompt can be set via the <var>message</var> attribute or as character data nested into the
  27. element.</p>
  28. <p>Optionally a set of valid input arguments can be defined via the <var>validargs</var>
  29. attribute. <code>Input</code> task will not accept a value that doesn't match one of the
  30. predefined.</p>
  31. <p>Optionally a property can be created from the value entered by the user. This property can then
  32. be used during the following build run. <code>Input</code> then behaves
  33. as <a href="property.html">property task</a> which means that existing properties cannot be
  34. overridden. <em>Since Apache Ant 1.6</em>, <code>&lt;input&gt;</code> will not prompt for input if
  35. a property should be set by the task that has already been set in the project (and the task wouldn't
  36. have any effect).</p>
  37. <p>Historically, a regular complaint about this task has been that it echoes characters to the
  38. console, this is a critical security defect, we must fix it immediately, etc, etc. This problem was
  39. due to the lack in early versions of Java of a (fully functional) facility for handling secure
  40. console input. In Java 6 that shortcoming in Java's API was addressed and Ant versions 1.7.1 and
  41. 1.8 have added support for Java 6 secure console input feature (see <a href="#handler.type">handler
  42. type</a>).</p>
  43. <p>IDE behaviour depends upon the IDE: some hang waiting for input, some let you type it in. For
  44. this situation, place the password in a (secured) property file and load in before
  45. the <code>input</code> task.</p>
  46. <h3>Parameters</h3>
  47. <table class="attr">
  48. <tr>
  49. <th scope="col">Attribute</th>
  50. <th scope="col">Description</th>
  51. <th scope="col">Required</th>
  52. </tr>
  53. <tr>
  54. <td>message</td>
  55. <td>the Message which gets displayed to the user during the build run.</td>
  56. <td>No</td>
  57. </tr>
  58. <tr>
  59. <td>validargs</td>
  60. <td>comma separated String containing valid input arguments. If set, <code>input</code> task
  61. will reject any input not defined here. Comparison of input to <var>validargs</var> is case
  62. sensitive. If you want <q>a</q> and
  63. <q>A</q> to be accepted you will need to define both arguments within <var>validargs</var>.</td>
  64. <td>No</td>
  65. </tr>
  66. <tr>
  67. <td>addproperty</td>
  68. <td>the name of a property to be created from input. Behaviour is equal
  69. to <a href="property.html">property task</a> which means that existing properties cannot be
  70. overridden.</td>
  71. <td>No</td>
  72. </tr>
  73. <tr>
  74. <td>defaultvalue</td>
  75. <td>Defines the default value of the property to be created from input. Property value will be
  76. set to default if no input is received.</td>
  77. <td>No</td>
  78. </tr>
  79. </table>
  80. <h3>Parameters specified as nested elements</h3>
  81. <h4>Handler</h4>
  82. <p><em>Since Ant 1.7</em>, a nested <code>&lt;handler&gt;</code> element can be used to specify
  83. an <code>InputHandler</code>, so that different <code>InputHandler</code>s may be used among
  84. different <code>Input</code> tasks.</p>
  85. <table class="attr">
  86. <tr>
  87. <th scope="col">Attribute</th>
  88. <th scope="col">Description</th>
  89. <th scope="col">Required</th>
  90. </tr>
  91. <tr id="handler.type">
  92. <td>type</td>
  93. <td>one of <q>default</q>, <q>propertyfile</q>, <q>greedy</q>, or <q>secure</q> (<em>since Ant
  94. 1.8</em>).</td>
  95. <td rowspan="3">One of these</td>
  96. </tr>
  97. <tr>
  98. <td>refid</td>
  99. <td class="left">Reference to an <code>InputHandler</code> defined elsewhere in the
  100. project.</td>
  101. </tr>
  102. <tr>
  103. <td>classname</td>
  104. <td class="left">The name of an <code>InputHandler</code> subclass.</td>
  105. </tr>
  106. <tr>
  107. <td>classpath</td>
  108. <td>The classpath to use with <var>classname</var>.</td>
  109. <td>No</td>
  110. </tr>
  111. <tr>
  112. <td>classpathref</td>
  113. <td>The refid of a classpath to use with <var>classname</var>.</td>
  114. <td>No</td>
  115. </tr>
  116. <tr>
  117. <td>loaderref</td>
  118. <td>The refid of a classloader to use with <var>classname</var>.
  119. </td>
  120. <td>No</td>
  121. </tr>
  122. </table>
  123. <p>The classpath can also be specified by means of one or more nested <code>&lt;classpath&gt;</code>
  124. elements.</p>
  125. <h3>Examples</h3>
  126. <p>Pause the build run until return key is pressed when using
  127. the <a href="../inputhandler.html#defaulthandler">default InputHandler</a>, the concrete behavior is
  128. defined by the <code>InputHandler</code> implementation you use.</p>
  129. <pre>&lt;input/&gt;</pre>
  130. <p>Display the message <q>Press Return key to continue...</q> and pause the build run until return
  131. key is pressed (again, the concrete behavior is implementation dependent).</p>
  132. <pre>&lt;input&gt;Press Return key to continue...&lt;/input&gt;</pre>
  133. <p>Display the message <q>Press Return key to continue...</q> and pause the build run until return
  134. key is pressed (see above).</p>
  135. <pre>&lt;input message=&quot;Press Return key to continue...&quot;/&gt;</pre>
  136. <p>Display the message <q>All data is going to be deleted from DB continue (y/n)?</q> and
  137. require <q>y</q> to continue build or <q>n</q> to exit build with following message <q>Build aborted
  138. by user.</q>.</p>
  139. <pre>
  140. &lt;input message=&quot;All data is going to be deleted from DB continue (y/n)?&quot;
  141. validargs=&quot;y,n&quot;
  142. addproperty=&quot;do.delete&quot;/&gt;
  143. &lt;condition property=&quot;do.abort&quot;&gt;
  144. &lt;equals arg1=&quot;n&quot; arg2=&quot;${do.delete}&quot;/&gt;
  145. &lt;/condition&gt;
  146. &lt;fail if=&quot;do.abort&quot;&gt;Build aborted by user.&lt;/fail&gt;
  147. </pre>
  148. <p>Display the message <q>Please enter db-username:</q> and set the property <code>db.user</code> to
  149. the value entered by the user.</p>
  150. <pre>
  151. &lt;input message=&quot;Please enter db-username:&quot;
  152. addproperty=&quot;db.user&quot;/&gt;</pre>
  153. <p>Same as above, but set <code>db.user</code> to the value <q>Scott-Tiger</q> if the user enters no
  154. value (simply presses <q>return</q>).</p>
  155. <pre>
  156. &lt;input message=&quot;Please enter db-username:&quot;
  157. addproperty=&quot;db.user&quot;
  158. defaultvalue=&quot;Scott-Tiger&quot;/&gt;</pre>
  159. </body>
  160. </html>