You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Baldry, Scot M" <Sc...@gs.com> on 2003/05/09 15:12:47 UTC
Getting input in a custom ant task
Hi,
I'm trying to write a custom ant task that will essentially jar up a
collection of classes and store an internal readme.txt that contains the
developers comments on why the changes have been packaged. To achieve this I
have extended the existing 'Zip' task and added my own routines to prompt
for comments and compose the readme.txt file.
The problem I am having is that the following lines of code cause very
strange behaviour when run as part of the task:
System.out.print("\nWould you like to continue (Y/N): ");
String response = input.readLine();
if (response.equalsIgnoreCase("Y"))
return true;
else if (response.equalsIgnoreCase("N"))
return false;
Basically, the build appears to hang but is infact waiting for input. When I
enter something and press return the output shows the line "Would you like
to continue?" - even though it appears before the input.readLine statement.
Since I do this in several places within the task I have made sure that the
various BufferedReaders that I use to grab input are being closed in the
relevant finally blocks.
I'm running Ant 1.5 on JDK 1.4.1 - as far as I can remember similar code ran
without problems under Ant 1.3 and Ant 1.4 under JDK 1.3. Anyone able to
provide an insight as to what may be happening?
Scot