tags:

views:

292

answers:

2

I have a main build file with a path declaration

<path id="path.app.src">
  <pathelement location="myfolder/src"/>
</path>

Then i call a task in sub file with <ant>

<ant antfile="subbuild.xml" inheritAll="false" inheritRefs="false">
    <reference refid="path.app.src"/>
</ant>

in subbuild.xml i have:

<path id="subpath.app.src">
  <pathelement location=".. some locations .."/>
  <path refid="path.app.src" />
</path>

In my understanding the call to <ant> with a nested should overwrite path.app.src in subbuild.xml.

But i get an error like: subbuild.xml:xx: Reference path.app.src not found.

Am i doing something wrong ? is it a bug in ant ?

I'm using Apache Ant version 1.7.0 compiled on December 13 2006

Thanks, Lionel

A: 

Can you post the full build files that are failing? I just tried to reproduce this error, but it is working fine for me with Ant 1.7.0.

Nate
A: 

in fact it seems to have the right behavior now, but i can't explain what i did wrong the first time.

here is the code sample: build.xml

<?xml version="1.0"?>
<project name="test" default="build" basedir=".">

    <path id="mainpath">
        <pathelement location="my/main/path"/>
    </path>

    <target name="build">
        <ant antfile="subbuild.xml" target="test">
            <reference refid="mainpath" torefid="globalpathid"/>
            <reference refid="mainpath" torefid="localtotargetpathid"/> 
        </ant>
    </target>    
</project>

subbuild.xml

<?xml version="1.0"?>
<project name="subbuild">

    <path id="globalpathid">
        <pathelement location="my/sub/location"/>
    </path>
    <target name="test">
        <path id="localtotargetpathid">
            <pathelement location="my/target/location"/>
        </path>
       <property name="p.localtotargetpathid" refid="localtotargetpathid" />

       <echo>p.localtotargetpathid: ${p.localtotargetpathid}</echo>

       <property name="p.globalpathid" refid="globalpathid" />

       <echo>p.globalpathid: ${p.globalpathid}</echo>

    </target>   
</project>

here is the console log:

$ ant
Buildfile: build.xml

build:
      [ant] Parent project doesn't contain any reference 'mainpath'

test:
     [echo] p.localtotargetpathid: d:\my\target\location
     [echo] p.globalpathid: d:\my\main\path

BUILD SUCCESSFUL
Total time: 0 seconds

we can see globalpathid has been override but not localtotargetpathid, which is the behvior mentioned in the spec.

still I can't explain the first message ...

Lionel
i meant the first message: [ant] Parent project doesn't contain any reference 'mainpath'
Lionel