ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastien Diot <s.d...@eurodata.de>
Subject How to get the calling target in a script?
Date Wed, 27 Mar 2002 11:43:25 GMT
Most of our build.xml looks like this:

	<target name="CalcExt" depends="edlohn-enhanced,eurodata,PayrollExt">
		<antcall target="buildSubDir">
			<param name="subDir" value="CalcExt"/>
			<param name="classpath" 
value="${build}/edlohn-enhanced.jar:${build}/eurodata.jar:${build}/Payro  
llExt.jar"/>
		</antcall>
	</target>

We antcall buildSubDir with the calling target name, and its dependencies 
turned into a classpath.

What I would like is to simply say:

	<target name="CalcExt" 
depends="edlohn-enhanced,eurodata,PayrollExt,buildDir"/>

With buildDir defined as a script, so that it fetches the calling target 
name and dependencies, and uses that to call buildSubDir like in the first 
example:

	<target name="buildDir">
		<script language="javascript"> <![CDATA[
			callingTaget = "CalcExt";
			projectname = lohn;
			dep = projectname.getTargets().get(callingTaget).getDependencies();
			buildDir = ":" + projectname.getProperty("build") + "/";
			cp = "";
			while(dep.hasMoreElements()) {
				cp = cp + buildDir + dep.nextElement() + ".jar";
			}
			strbuf = new java.lang.StringBuffer(cp);
			if (strbuf.length() > 0) {
				strbuf.deleteCharAt(0);
			}
			projectname.setProperty("buildDir.classpath", strbuf.toString());
			projectname.setProperty("buildDir.dir", callingTaget);
		]]></script>
		<antcall target="buildSubDir">
			<param name="subDir" value="${buildDir.dir}"/>
			<param name="classpath" value="${buildDir.classpath}"/>
		</antcall>
	</target>

So, what can I do to get the name of the calling target, so that I can set 
it in the variable callingTaget ?

MfG / Regards,
Sebastien Diot

eurodata GmbH & Co. KG
Gro?blittersdorfer Str. 257-259
66119 Saarbrucken

Tel: 0681 8808 796
Fax: 0681 8808 300



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


Mime
View raw message