我有一个电话给 Ant exec
需要接受来自控制台标准输入的输入的任务。不幸的是,我找不到办法做到这一点。 stdin 文件句柄在运行时似乎对控制台输入关闭。
可以使用属性 input
指定输入和 inputstring
.但是,我需要在控制台提示用户输入。
我怎样才能做到这一点?
最佳答案
来自 documentation任务:
Note that you cannot interact with the forked program, the only way to send input to it is via the input and inputstring attributes. Also note that since Ant 1.6, any attempt to read input in the forked program will receive an EOF (-1). This is a change from Ant 1.5, where such an attempt would block.
您可以尝试使用 input-task提示在 ant-buildfile 中输入并使用 exec 的 inputstring-attribute 传递这些输入。我暂时想不出更好的选择。
关于Ant exec 任务 : How can I read input from console stdin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4176305/