コード例 #1
0
ファイル: ANTLR.java プロジェクト: BIORIMP/biorimp
 /**
  * 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");
   }
 }
コード例 #2
0
ファイル: TestRunnerTask.java プロジェクト: xjie/fitnesse
  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;
  }
コード例 #3
0
ファイル: ANTLR.java プロジェクト: saeg/experiments
  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());
      }
    }
  }
コード例 #4
0
ファイル: ANTLR.java プロジェクト: BIORIMP/biorimp
 /**
  * Whether the antlr version is 2.7.2 (or higher).
  *
  * @return true if the version of Antlr present is 2.7.2 or later.
  * @since Ant 1.6
  */
 protected boolean is272() {
   AntClassLoader l = null;
   try {
     l = getProject().createClassLoader(commandline.getClasspath());
     l.loadClass("antlr.Version");
     return true;
   } catch (ClassNotFoundException e) {
     return false;
   } finally {
     if (l != null) {
       l.cleanup();
     }
   }
 }
コード例 #5
0
ファイル: TestRunnerTask.java プロジェクト: xjie/fitnesse
 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;
 }
コード例 #6
0
ファイル: ANTLR.java プロジェクト: BIORIMP/biorimp
  /**
   * 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);
    }
  }
コード例 #7
0
ファイル: ANTLR.java プロジェクト: BIORIMP/biorimp
 /** Constructor for ANTLR task. */
 public ANTLR() {
   commandline.setVm(JavaEnvUtils.getJreExecutable("java"));
   commandline.setClassname("antlr.Tool");
 }
コード例 #8
0
ファイル: ANTLR.java プロジェクト: BIORIMP/biorimp
 /**
  * Adds a new JVM argument.
  *
  * @return create a new JVM argument so that any argument can be passed to the JVM.
  * @see #setFork(boolean)
  */
 public Commandline.Argument createJvmarg() {
   return commandline.createVmArgument();
 }
コード例 #9
0
ファイル: ANTLR.java プロジェクト: BIORIMP/biorimp
 /**
  * Adds a classpath to be set because a directory might be given for Antlr debug.
  *
  * @return a path to be configured
  */
 public Path createClasspath() {
   return commandline.createClasspath(getProject()).createPath();
 }
コード例 #10
0
ファイル: ANTLR.java プロジェクト: saeg/experiments
 public ANTLR() {
   commandline.setVm("java");
   commandline.setClassname("antlr.Tool");
 }