/** * A refactored method for populating all the command line arguments based on the user-specified * attributes. */ private void populateAttributes() { commandline.createArgument().setValue("-o"); commandline.createArgument().setValue(outputDirectory.toString()); if (superGrammar != null) { commandline.createArgument().setValue("-glib"); commandline.createArgument().setValue(superGrammar.toString()); } if (html) { commandline.createArgument().setValue("-html"); } if (diagnostic) { commandline.createArgument().setValue("-diagnostic"); } if (trace) { commandline.createArgument().setValue("-trace"); } if (traceParser) { commandline.createArgument().setValue("-traceParser"); } if (traceLexer) { commandline.createArgument().setValue("-traceLexer"); } if (traceTreeWalker) { if (is272()) { commandline.createArgument().setValue("-traceTreeParser"); } else { commandline.createArgument().setValue("-traceTreeWalker"); } } if (debug) { commandline.createArgument().setValue("-debug"); } }
private CommandlineJava initializeJavaCommand() { CommandlineJava cmd = new CommandlineJava(); cmd.setClassname(testRunnerClass); cmd.createVmArgument().setValue("-Xmx100M"); if (verbose) cmd.createArgument().setValue("-v"); if (resultsXMLPage != null) { String resultsHTMLPagePath = new File(resultsDir, resultsXMLPage).getAbsolutePath(); cmd.createArgument().setValue("-xml"); cmd.createArgument().setValue(resultsHTMLPagePath); } cmd.createArgument().setValue("localhost"); cmd.createArgument().setValue(String.valueOf(fitnessePort)); cmd.createArgument().setValue(suitePage); cmd.createClasspath(getProject()).createPath().append(classpath); return cmd; }
public void execute() throws BuildException { validateAttributes(); // TODO: use ANTLR to parse the grammer file to do this. if (target.lastModified() > getGeneratedFile().lastModified()) { commandline.createArgument().setValue("-o"); commandline.createArgument().setValue(outputDirectory.toString()); commandline.createArgument().setValue(target.toString()); if (fork) { log("Forking " + commandline.toString(), Project.MSG_VERBOSE); int err = run(commandline.getCommandline()); if (err == 1) { throw new BuildException("ANTLR returned: " + err, location); } } else { Execute.runCommand(this, commandline.getCommandline()); } } }
/** * 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); } }