Workaround: <?xml version="1.0" encoding="ISO-8859-1"?> <project name="test" basedir="." default="main">
<target name="main"> <script language="javascript"> <![CDATA[ name = self.getOwningTarget().getName(); project.setProperty("target.name",name); ]]></script> <echo>target.name=${target.name}</echo> <antcall target="script"/> </target> <target name="script"> <script language="javascript"> <![CDATA[ name = self.getOwningTarget().getName(); project.setProperty("target.name",name); ]]></script> <echo>target.name=${target.name}</echo> </target> </project> But itīs not the fine way to overwrite the property ... I think it is no problem to implement. But then we will brake to golden rule "properties are immutable" (see example). If you have to specify the property in which the target name should be stored, you can code that in a normal <property/>. (... I got an idea ...) If you want to have a "global" property (like ant.project.name) the value has to overwritten in each target (otherwise it wouldnīt be really useful). Back to my idea: A task which gets the current target name and tries to store it into a property. Maybe it should fail if that property is already set (to a different value). <target name="helloWorld"> <getTargetName property="tname"/> <echo>${tname}</echo> </target> would print "helloWorld" <getTargetName property="tname" fail="never|differ|isset"/> control the behaviour if the property tname is already set - never: donīt throw a BuildException (log in verbose); donīt set the property --> "properties are immutable" - differ: throw a BE if the value differs from the current target name; donīt set the property (useless, has the "right" value :-) - isset: throw a BE if the property is set; set the property Would that help? Jan > -----Original Message----- > From: Sean Rohead [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 24, 2003 1:42 AM > To: [EMAIL PROTECTED] > Subject: Bug 3304 > > > I wanted to lobby for bug 3304 as an enhancement. I have an > ant script > which calls subordinate ant scripts using the <ant> task. I > would like > to pass the build target to the subordinate scripts so they > can execute > the same target as the parent (ie. 'ant compile' calls the compile > target on the subordinate projects). Without a means of accessing the > target name, I would have to hardcode the target and therefore need to > place <ant> tasks within every single target in the parent build file. > Am I missing something? Is there another way to accomplish > this without > a standard ant.target.name property? > > > > Thanks, > > > > Sean Rohead > >