private int executeRunnerClassAsForked() throws BuildException { CommandlineJava cmd = initializeJavaCommand(); Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); execute.setCommandline(cmd.getCommandline()); execute.setNewenvironment(false); execute.setAntRun(getProject()); log(cmd.describeCommand(), Project.MSG_VERBOSE); int retVal; try { retVal = execute.execute(); } catch (IOException e) { throw new BuildException("Process fork failed.", e, getLocation()); } return retVal; }
/** * Execute the task. * * @throws BuildException on error */ public void execute() throws BuildException { validateAttributes(); // TODO: use ANTLR to parse the grammar file to do this. File generatedFile = getGeneratedFile(); boolean targetIsOutOfDate = targetFile.lastModified() > generatedFile.lastModified(); boolean superGrammarIsOutOfDate = superGrammar != null && (superGrammar.lastModified() > generatedFile.lastModified()); if (targetIsOutOfDate || superGrammarIsOutOfDate) { if (targetIsOutOfDate) { log( "Compiling " + targetFile + " as it is newer than " + generatedFile, Project.MSG_VERBOSE); } else { log( "Compiling " + targetFile + " as " + superGrammar + " is newer than " + generatedFile, Project.MSG_VERBOSE); } populateAttributes(); commandline.createArgument().setValue(targetFile.toString()); log(commandline.describeCommand(), Project.MSG_VERBOSE); int err = run(commandline.getCommandline()); if (err != 0) { throw new BuildException("ANTLR returned: " + err, getLocation()); } else { String output = bos.toString(); if (output.indexOf("error:") > -1) { throw new BuildException("ANTLR signaled an error: " + output, getLocation()); } } } else { log( "Skipped grammar file. Generated file " + generatedFile + " is newer.", Project.MSG_VERBOSE); } }