Klaus Nji
Klaus Nji

Reputation: 18857

Ant script import overriding main path id name

Say I have the following Ant script:

<project name = "imported">
   <path id="same.classpath>
     <pathelement location="c:\temp\imported"/>
   </path>
   <target name="imported.echo">
    <echo>hell from import</echo>
  </target>
</project>

that will be imported into this one:

<project name = "importer">
   <path id="same.classpath>
     <pathelement location="c:\temp\importer"/>
   </path>

   <import file="imported.xml" as="i" />

   <target name="importer.echo" depends="i.imported.echo">
    <echo>hell from import</echo>
  </target>
</project>

When I run the second script, it seems as if the path referenced by same.classpath in importer.xml is not used. Instead the one referenced by imported (c:\temp\imported) is being used. If I assign unique names for the path id, I do not run into this problem, hence the guess.

From my understanding of the literature, properties from the main file take precedence. But this is not what I am observing. Did I miss something?

Upvotes: 3

Views: 1113

Answers (1)

martin clayton
martin clayton

Reputation: 78155

In this case what's being overwritten is not a property but a reference id. Unlike properties the referee - what the reference id is associated with - can be changed during a build, which is what you observe.

Upvotes: 1

Related Questions