source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual/manual/CoreTasks/input.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

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