Ejemplo n.º 1
0
  /**
   * Runs the given target on the provided build file.
   *
   * @param file the build file to execute
   * @param directory the directory of the current iteration
   * @throws BuildException is the file cannot be found, read, is a directory, or the target called
   *     failed, but only if <code>failOnError</code> is <code>true</code>. Otherwise, a warning log
   *     message is simply output.
   */
  private void execute(File file, File directory) throws BuildException {
    if (!file.exists() || file.isDirectory() || !file.canRead()) {
      String msg = "Invalid file: " + file;
      if (failOnError) {
        throw new BuildException(msg);
      }
      log(msg, Project.MSG_WARN);
      return;
    }

    ant = createAntTask(directory);
    String antfilename = file.getAbsolutePath();
    ant.setAntfile(antfilename);
    try {
      ant.execute();
    } catch (BuildException e) {
      if (failOnError) {
        throw e;
      }
      log(
          "Failure for target '" + target + "' of: " + antfilename + "\n" + e.getMessage(),
          Project.MSG_WARN);
    } catch (Throwable e) {
      if (failOnError) {
        throw new BuildException(e);
      }
      log(
          "Failure for target '" + target + "' of: " + antfilename + "\n" + e.toString(),
          Project.MSG_WARN);
    } finally {
      ant = null;
    }
  }
Ejemplo n.º 2
0
  public void execute() {
    if (!initialized) {
      init();
    }

    if (subTarget == null) {
      throw new BuildException("Attribute target is required.", location);
    }

    callee.setDir(project.getBaseDir());
    callee.setAntfile(project.getProperty("ant.file"));
    callee.setTarget(subTarget);
    callee.setInheritAll(inheritAll);
    callee.execute();
  }
Ejemplo n.º 3
0
  /**
   * hand off the work to the ant task of ours, after setting it up
   *
   * @throws BuildException on validation failure or if the target didn't execute
   */
  public void execute() throws BuildException {
    if (callee == null) {
      init();
    }

    if (subTarget == null) {
      throw new BuildException("Attribute target is required.", getLocation());
    }

    callee.setAntfile(getProject().getProperty("ant.file"));
    callee.setTarget(subTarget);
    callee.setInheritAll(inheritAll);
    callee.setInheritRefs(inheritRefs);
    callee.execute();
  }