Hi Thanks for the input Mark.
After some researching I found the same issue logged as a bug here: https://issues.apache.org/bugzilla/show_bug.cgi?id=42544 Quick Solution: I used the DefaultInputHandler from apache-ant-1.6.5 http://ant.apache.org/manual/CoreTasks/input.html http://ant.apache.org/manual/inputhandler.html#defaulthandler Cheers, Michael -------- Original Message -------- Subject: Re: "Failed to read input from Console" Error invoking ant from java class From: Mark Salter <[email protected]> To: Ant Users List <[email protected]> Date: mon, 15 dec 2008 21:28:38 +0000 > 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. > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
