ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Martin" <antu...@gmail.com>
Subject Use of Project.executeTarget(String)
Date Tue, 06 Jun 2006 13:23:19 GMT
Hello,

Probably a dum question : is is authorized (ie not dangerous) to use
the method Project.executeTarget(String) ?

The following would create a task that calls a target. The properties
set in this target get created in the calling project.

public class TargetCaller extends Task {
	private String target = null;
	public void setTarget(String target) {
		this.target = target;
	}
	public void execute() {
		//execute named target with associated dependencies
		getProject().executeTarget(target);
	}
}

Use case:

<taskdef name="call" classname="TargetCaller" />
<target name="default">
	<call target="set"/>
	<echo message="p = ${p}" />
</target>
<target name="set" depends="a">
	<property name="p" value="v" />
</target>
<target name="a">
	<echo message="in a" />
</target>

Will output:
Buildfile: build.xml
default:
a:
     [echo] in a
set:
     [echo] p = v
BUILD SUCCESSFUL

Is it rightful ?

I don't really need the feature but it seems that it could be useful
to replace some <antcall> with property file management sometimes.

Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message