Exemple #1
0
  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());
      }
    }
  }
Exemple #2
0
  private void validateAttributes() throws BuildException {
    if (target == null || !target.isFile()) {
      throw new BuildException("Invalid target: " + target);
    }

    // if no output directory is specified, used the target's directory
    if (outputDirectory == null) {
      String fileName = target.toString();
      setOutputdirectory(new File(target.getParent()));
    }
    if (!outputDirectory.isDirectory()) {
      throw new BuildException("Invalid output directory: " + outputDirectory);
    }
    if (fork && (dir == null || !dir.isDirectory())) {
      throw new BuildException("Invalid working directory: " + dir);
    }
  }
Exemple #3
0
 public void setOutputdirectory(File outputDirectory) {
   log("Setting output directory to: " + outputDirectory.toString(), Project.MSG_VERBOSE);
   this.outputDirectory = outputDirectory;
 }
Exemple #4
0
 public void setTarget(File target) {
   log("Setting target to: " + target.toString(), Project.MSG_VERBOSE);
   this.target = target;
 }