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

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