ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "didge" <di...@foundrylogic.com>
Subject <antexec>
Date Thu, 06 Feb 2003 00:56:36 GMT
Has anyone written a Task that would be to CallTarget as exec is to fork in
unix?  That is, unlike CallTarget which essentially re-inits the project,
'ExecTarget' would simply execute the named target.  I can't find anything
like it in the ant 1.5.1 source or in my internet searching.

For example:

	<target name="aTarget">
		...
	</target>

	<target name="bTarget">
		<antexec target="aTarget"/>
	</target>

In my projects, I have some deeply nested <antcall>s and I was shocked at
how much faster my build ran when I used this ExecTarget implementation
instead:

import org.apache.tools.ant.*;

/**
 * Exec another target in the same project.
 *
 *  <pre>
 *    &lt;target name="foo"&gt;
 *      &lt;antexec target="bar" /&gt;
 *    &lt;/target&gt;
 *
 *    &lt;target name="bar" depends="init"&gt;
 *      ...
 *    &lt;/target&gt;
 * </pre>
 *
 *
 * @author <a href="mailto:didge@foundrylogic.com">didge</a>
 *
 * @ant.task name="antexec" category="control"
 */
public class ExecTarget extends Task {
    private String target;

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public void execute() throws BuildException {
        project.executeTarget(target);
    }
}

Are there any reasons why I wouldn't want to do this, assuming that I want
to be able to side affect my project and I don't want the overhead of
re-init'ing?


Dave Masser-Frye
didge@foundrylogic.com


Mime
View raw message