From 82e6aad2041eedda98525856f6ab515986772593 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 4 Aug 2000 14:58:43 +0000 Subject: [PATCH] Make Jikes use the new Execute class instead of calling Runtime.exec itself. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267888 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 2 +- .../org/apache/tools/ant/taskdefs/Javac.java | 2 +- .../org/apache/tools/ant/taskdefs/Jikes.java | 14 +++++--- .../tools/ant/taskdefs/JikesOutputParser.java | 33 ++++++++++++++++++- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/build.xml b/build.xml index 79fb8ddc2..26df439cf 100644 --- a/build.xml +++ b/build.xml @@ -32,7 +32,7 @@ - + diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index 0a5c877df..c4a76a039 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -748,7 +748,7 @@ public class Javac extends MatchingTask { JikesOutputParser jop = new JikesOutputParser(this, emacsMode); - Jikes compiler = new Jikes(jop,"jikes"); + Jikes compiler = new Jikes(jop, "jikes", project); compiler.compile(args); if (jop.getErrorFlag()) { String msg = "Compile failed, messages should have been provided."; diff --git a/src/main/org/apache/tools/ant/taskdefs/Jikes.java b/src/main/org/apache/tools/ant/taskdefs/Jikes.java index 05b70e8c2..88ce018ab 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Jikes.java +++ b/src/main/org/apache/tools/ant/taskdefs/Jikes.java @@ -13,16 +13,18 @@ import java.util.Random; public class Jikes { protected JikesOutputParser jop; protected String command; - + protected Project project; + /** * Constructs a new Jikes obect. * @param jop - Parser to send jike's output to * @param command - name of jikes executeable */ - protected Jikes(JikesOutputParser jop,String command) { + protected Jikes(JikesOutputParser jop,String command, Project project) { super(); this.jop = jop; this.command = command; + this.project = project; } /** @@ -71,9 +73,11 @@ public class Jikes { // -Xstdout that is given to Jikes in Javac.doJikesCompile() // should guarantee this. At least I hope so. :) try { - Process jikes = Runtime.getRuntime().exec(commandArray); - BufferedReader reader = new BufferedReader(new InputStreamReader(jikes.getInputStream())); - jop.parseOutput(reader); + Execute exe = new Execute(jop); + exe.setAntRun(project); + exe.setWorkingDirectory(project.getBaseDir()); + exe.setCommandline(commandArray); + exe.execute(); } catch (IOException e) { throw new BuildException("Error running Jikes compiler", e); } diff --git a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java index f9ddb889c..931da097b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java +++ b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java @@ -13,13 +13,44 @@ import java.io.*; * Parsing could be much better * @author skanthak@muehlheim.de */ -public class JikesOutputParser { +public class JikesOutputParser implements ExecuteStreamHandler { protected Task task; protected boolean errorFlag = false; // no errors so far protected int errors,warnings; protected boolean error = false; protected boolean emacsMode; + protected BufferedReader br; + + /** + * Ignore. + */ + public void setProcessInputStream(OutputStream os) {} + + /** + * Ignore. + */ + public void setProcessErrorStream(InputStream is) {} + + /** + * Set the inputstream + */ + public void setProcessOutputStream(InputStream is) throws IOException { + br = new BufferedReader(new InputStreamReader(is)); + } + + /** + * Invokes parseOutput. + */ + public void start() throws IOException { + parseOutput(br); + } + + /** + * Ignore. + */ + public void stop() {} + /** * Construct a new Parser object * @param task - task in whichs context we are called