No, that is not the same thing. That does not allow me to run just the 'borland' target. Your dependency list will also cause 'all' to run when I run "ant borland". I want the reverse -- when "ant all" is run, all targets should build. It could almost be done with dependencies alone, but not if the 'all' target has some processing it must do before the dependent targets run.

Just for grins, I wrote a new task called "DO" which works just like ANTCALL except that it recursively runs dependencies and keeps a static list of already-run targets. In the dependency analysis it skips targets that have already run. So my code now looks like:

  <target name="all" depends="init, compile">
    ... do some prep work here...
    <do target="borland"/>
    <do target="weblogic"/>
  </target>

The code is almost trivial... just a little recursion and a static hash table:

public class Do extends Task {
        private String targetName;
        private static Hashtable hasRunList = new Hashtable();

  public Do() {
  }
  public void setTarget(String targetName) {
    this.targetName = targetName;
  }
  public void execute() throws BuildException {
    // Get the target property
    if (targetName == null) {
      throw new BuildException("Missing 'target' parameter.", location);
    }
    runTarget(targetName);
  }

private void runTarget(String targetName) throws BuildException {
Target t = (Target)project.getTargets().get(targetName);
if (t == null) {
throw new BuildException("Target '"+targetName+"' not found.", location);
}


    // Run all dependencies (that have not yet been run) before running
    // the requested target.
    Enumeration enum = t.getDependencies();
    while (enum.hasMoreElements()) {
      String depName = (String)enum.nextElement();
      if (hasRunList.get(depName) == null) { // This target has never been run
        runTarget(depName); // Recursive call to run the dependent target
      }
    }

    // Now run the requested target
    t.performTasks();

    // Add to list of targets that have been run
    hasRunList.put(targetName, t);
  }
}


-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



Reply via email to