<input message="Please enter password:" addproperty="password.property"> <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> </input>SecureInputHandler需要Ant 1.7.1或更高版本(以支持处理程序)和Java 6或更高版本(以提供Console类).
如果您没有正确的Ant版本,则会出现错误.如果您没有正确的Java版本,Ant将回退到默认的输入处理程序.
请注意,您还可以使用:
<handler type="secure"/>
javadoc和source可以看到here.
在Windows cmd shell中使用Ant 1.8.2和Java 1.6,我得到了这个:
test: Please enter password:<cursor here>
密码被屏蔽.您键入密码并按Enter键.
在cmd shell中使用Cygwin shell或Java 1.5,我得到:
test: [input] Please enter password: <cursor here>
密码未被屏蔽.您键入密码并按Enter键.
使用Eclipse控制台,我根本无法输入密码.我键入,它在控制台上回显,我按Enter键,没有任何反应.
我注意到在Input任务的文档中,它说:
IDE behaviour depends upon the IDE: some hang waiting for input, some
let you type it in. For this situation, place the password in a (secured) property file and load in before the input task.
换句话说,它可能无法在IDE中工作,使用解决方法.
精彩评论