You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by sporty <sp...@gmail.com> on 2005/10/19 23:34:48 UTC

Conditionally create a path reference id

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

Building w/ -d for debug I bumped into this when it is enumerating the
targets:

+Target: dependencyRunTimeFalse
Adding reference: project.classpath.runtime

How can I get around this short of creating 10 other build scripts and
dynamically including them? (That's a lot of scripts)

Re: Conditionally create a path reference id

Posted by Dominique Devienne <dd...@gmail.com>.
On 10/19/05, sporty <sp...@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


Re: Conditionally create a path reference id

Posted by Juergen Hermann <jh...@web.de>.
On Wed, 19 Oct 2005 15:34:48 -0600, sporty wrote:

^><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

How is project.dependency.runtime set? You should do it via a <isrefeence> 
condition, and then it should work.

Ciao, Jürgen



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