conor 2003/06/10 06:29:56 Modified: src/main/org/apache/tools/ant DemuxInputStream.java Main.java Project.java src/main/org/apache/tools/ant/taskdefs LogOutputStream.java Redirector.java Log: Various I/O fixes to support input from java tasks. Addition of a -noinput flag to indicate input is not allowed to prevent locking up non-interactive builds. PR: 18133 Revision Changes Path 1.3 +3 -1 ant/src/main/org/apache/tools/ant/DemuxInputStream.java Index: DemuxInputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/DemuxInputStream.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -u -r1.2 -r1.3 --- DemuxInputStream.java 10 Feb 2003 14:13:30 -0000 1.2 +++ DemuxInputStream.java 10 Jun 2003 13:29:55 -0000 1.3 @@ -86,7 +86,9 @@ */ public int read() throws IOException { byte[] buffer = new byte[1]; - project.demuxInput(buffer, 0, 1); + if (project.demuxInput(buffer, 0, 1) == -1) { + return -1; + } return buffer[0]; } 1.83 +9 -1 ant/src/main/org/apache/tools/ant/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Main.java,v retrieving revision 1.82 retrieving revision 1.83 diff -u -w -u -r1.82 -r1.83 --- Main.java 15 Apr 2003 17:23:15 -0000 1.82 +++ Main.java 10 Jun 2003 13:29:55 -0000 1.83 @@ -108,6 +108,9 @@ /** File names of property files to load on startup. */ private Vector propertyFiles = new Vector(5); + /** Indicates whether this build is to support interactive input */ + private boolean allowInput = true; + /** * The Ant logger class. There may be only one logger. It will have * the right to use the 'out' PrintStream. The class must implements the @@ -280,6 +283,8 @@ } else if (arg.equals("-debug")) { printVersion(); msgOutputLevel = Project.MSG_DEBUG; + } else if (arg.equals("-noinput")) { + allowInput = false; } else if (arg.equals("-logfile") || arg.equals("-l")) { try { File logFile = new File(args[i + 1]); @@ -571,7 +576,9 @@ //System.setSecurityManager(new NoExitSecurityManager()); } try { + if (allowInput) { project.setDefaultInputStream(System.in); + } System.setIn(new DemuxInputStream(project)); System.setOut(new PrintStream(new DemuxOutputStream(project, false))); System.setErr(new PrintStream(new DemuxOutputStream(project, true))); @@ -751,6 +758,7 @@ msg.append(" -l <file> ''" + lSep); msg.append(" -logger <classname> the class which is to perform logging" + lSep); msg.append(" -listener <classname> add an instance of class as a project listener" + lSep); + msg.append(" -noinput do not allow interactive input" + lSep); msg.append(" -buildfile <file> use given buildfile" + lSep); msg.append(" -file <file> ''" + lSep); msg.append(" -f <file> ''" + lSep); 1.140 +2 -1 ant/src/main/org/apache/tools/ant/Project.java Index: Project.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Project.java,v retrieving revision 1.139 retrieving revision 1.140 diff -u -w -u -r1.139 -r1.140 --- Project.java 9 Jun 2003 13:38:06 -0000 1.139 +++ Project.java 10 Jun 2003 13:29:55 -0000 1.140 @@ -1087,6 +1087,7 @@ public int defaultInput(byte[] buffer, int offset, int length) throws IOException { if (defaultInputStream != null) { + System.out.flush(); return defaultInputStream.read(buffer, offset, length); } else { throw new EOFException("No input provided for project"); 1.10 +7 -0 ant/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java Index: LogOutputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -u -r1.9 -r1.10 --- LogOutputStream.java 10 Feb 2003 14:13:35 -0000 1.9 +++ LogOutputStream.java 10 Jun 2003 13:29:56 -0000 1.10 @@ -109,6 +109,13 @@ skip = (c == '\r'); } + /** + * Flush this log stream + */ + public void flush() { + processBuffer(); + } + /** * Converts the buffer to a string and sends it to <code>processLine</code> 1.5 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java Index: Redirector.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -u -r1.4 -r1.5 --- Redirector.java 14 Apr 2003 11:42:14 -0000 1.4 +++ Redirector.java 10 Jun 2003 13:29:56 -0000 1.5 @@ -399,6 +399,7 @@ outPrintStream = new PrintStream(outputStream); } outPrintStream.print(line); + outPrintStream.flush(); } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]