Browse Source

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
master
Stefan Bodewig 25 years ago
parent
commit
82e6aad204
4 changed files with 43 additions and 8 deletions
  1. +1
    -1
      build.xml
  2. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  3. +9
    -5
      src/main/org/apache/tools/ant/taskdefs/Jikes.java
  4. +32
    -1
      src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java

+ 1
- 1
build.xml View File

@@ -32,7 +32,7 @@
<property name="manifest" value="src/etc/manifest"/>

<property name="build.compiler" value="classic"/>
<property name="build.compiler.emacs" value="on"/>
<!-- <property name="build.compiler.emacs" value="on"/> -->

<!-- =================================================================== -->
<!-- Check to see what optional dependencies are available -->


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -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.";


+ 9
- 5
src/main/org/apache/tools/ant/taskdefs/Jikes.java View File

@@ -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);
}


+ 32
- 1
src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java View File

@@ -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


Loading…
Cancel
Save