ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: Bug 3304
Date Wed, 24 Sep 2003 07:19:11 GMT

<?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();
        <antcall target="script"/>

    <target name="script">
        <script language="javascript"> <![CDATA[
            name = self.getOwningTarget().getName();


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
you can code that in a normal <property/>. (... I got an idea ...)
If you want to have a "global" property (like the value
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

<target name="helloWorld">
    <getTargetName property="tname"/>

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
           --> "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?


> -----Original Message-----
> From: Sean Rohead []
> Sent: Wednesday, September 24, 2003 1:42 AM
> To:
> 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 property?
> Thanks,
> Sean Rohead

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message