ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <ddevie...@gmail.com>
Subject Re: Conditionally create a path reference id
Date Thu, 20 Oct 2005 14:17:07 GMT
On 10/19/05, sporty <sporte01@gmail.com> wrote:
> Hi, I'm trying to dynamically build 5 different path reference ids. I need
> them since you can't refer to a non existant reference id and rather not go
> through all the combinations of using them and not. I'd have n!
> combinations.
>
> So for each reference, I assign the set appropriate for it, or create one
> with nothing in it ala:
>
> <target name="dependencyRunTimeFalse" unless="project.dependency.runtime">
> <path id="project.classpath.runtime"/>
> </target>
>
> That's when I ran into this error:
>
> C:\development\eclipse 3.0\workspace\hibernate-3\common.xml:7: Reference ID
> project.classpath.runtime already exists

You must run into this error in a custom task, because Ant itself
issues a warning, and overrides the value associated to the id. The
task probably refused to override an existing ID, unlike Ant proper.

I think you problem comes from the fact that the id attribute is
handled specially in Ant, for historical reasons. I don't fully
understand how it behaves now in 1.6.x, when everything's an
UnknownElement, but basically id's are (used to be) assigned at
parsing time, rather than run time.

I've used a work around using a custom task that assign an id at
runtime. I've posted it on BugZilla somewhere. It allow to bypass
normal Ant id processing, and you take control of the id name you want
to use (you can also use properties to define the id name, unlike with
normal id attribute). It's a brittle mechanism though, since like I
said I don't fully comprehend id processing. --DD

    <!-- Define empty propertyset if not provided -->
    <condition property="propertyset-ref-defined">
      <isreference refid="propertyset" />
    </condition>
    <bm:sequential unlessTrue="${propertyset-ref-defined}">
      <echo>Using empty propertyset</echo>
      <bm:reference name="propertyset">
        <bm:propertyset />
      </bm:reference>
    </bm:sequential>

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


Mime
View raw message