ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: <antexec>
Date Thu, 06 Feb 2003 14:54:09 GMT
Yes, Centipede as one I believe. The reason it's not in Ant is that it
throws off the checks for circular dependencies between targets. Simply
consider:

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

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

Your <antexec> or Centipede <call> do make build faster, but not safer. The
right approach would be to make <antcall> lean and mean, by for example not
reparsing the build file, and Costin's made some progress in that regard.
Also not having the copy too much state from the parent Project to the child
Project would be good (by having additional/overridden state in the child
take priority over the Parent state).

So in short, it's all up to you to decide what is important to you! Every
situation is different of course; by the more I learn about Ant, the less I
need to rely on <antcall> for my own builds...

Does this help? --DD

-----Original Message-----
From: didge [mailto:didge@foundrylogic.com] 
Sent: Wednesday, February 05, 2003 6:57 PM
To: Ant Users List
Subject: <antexec>

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