| "Call " task | "Call " task 2003-03-06 - By Dale Anson
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
|
|
 |