ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Salter <marksal...@talktalk.net>
Subject Re: "Failed to read input from Console" Error invoking ant from java class
Date Mon, 15 Dec 2008 21:28:38 GMT
Michael Sobremonte wrote:
> 
> I am trying to call an ant target requiring input from within a java class.
Why do you want to do it this way?

Why not use ant natively or System.in directly from java *before*
invoking ant to react to the options selected?


> # INPUT MENU 1:
> <input message="Select an option:"  validargs="1,2,X"
> addproperty="main.option"/>
> 
> # INPUT MENU 2:
> <input message="Select an option:" validargs="Y,N"
> addproperty="abort.option"/>

It works as designed when running ant with a build file of :-

<project name="inputtest" default="build">
        <target name="build">
	   <input message="Select an option:"  validargs="1,2,X"
	      addproperty="main.option"/>

	   <input message="Select an option:" validargs="Y,N"
	      addproperty="abort.option"/>
        </target>

</project>

To get this to work in code, you are going to have to copy what ant does
for *each* input task.

> 
> In the above example, as soon as "X" is entered for INPUT MENU 1 and the
> INPUT MENU 2 message is displayed,
> ant will fail with a "Failed to read input from Console." message
> pointing to the the INPUT MENU 2 line.

I imagine is is related to how you are passing in a *single* "System.in"
in on your ant invocation, which successive input tasks are trying to
reuse and fighting over.

You are using ant in a non standard way, and are going to have to do
more investigation yourself to see what ant does with console input to
make it work, or adjust your approach.

The ant input task is not broken, I think you are breaking it by
invoking it in the way you are which appears to be in conflict with how
it was developed.

> 
> My AntInvoker class is similiar to the example in:
> http://www.ibm.com/developerworks/websphere/library/techarticles/0502_gawor/0502_gawor.html
This example only deals with output, not input which are quite different
in their mechanisms.

Good luck.

-- 
Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message