ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale Anson <dan...@germane-software.com>
Subject "Call" task
Date Thu, 06 Mar 2003 22:01:27 GMT
Just sharing --

A common question on this list is how to get a property set in a target 
after doing an <antcall>, the common answer is "you can't". I wrote a 
very simple task, so simple in fact that I've included the complete code 
below. Like AntCall, this task just calls a target in the current build 
file. The difference is that all properties from the calling target are 
available to the called target, and any properties set by the called 
target are immediately available in the calling target. Makes me wonder 
why AntCall wasn't written like this?

<shameless plug>
I posted a new version of Antelope today, 
http://antelope.sourceforge.net. This task is included.
</shameless plug>

package ise.antelope.tasks;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;

public class Call extends Task {
    private String target = null;
    public void setTarget(String target) {
     this.target = target;    }
    public void execute() {
     if (target == null)
        throw new BuildException("target is required");
     getProject().executeTarget(target);
  }
}


Dale Anson



Mime
View raw message