Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I use inherited references outside a target on ant (1.8.1)?

Tags:

reference

ant

All I want to do is set a reference to a path on a parent build.xml and use it on a child build.xml (called with <ant>). Here's the simplest example I could create:

build-parent.xml

<?xml version="1.0"?>
<project name="parent" default="do-parent">
    <target name="do-parent">
        <path id="inherited.path"/>
        <ant antfile="build-child.xml" inheritrefs="false" inheritall="false">
            <reference refid="inherited.path"/>
        </ant>
    </target>
</project>

build-child.xml

<?xml version="1.0"?>
<project name="child" default="do-child">
    <pathconvert property="converted.path" refid="inherited.path"/>
    <target name="do-child"/>
</project>

I run ant.bat -f build-parent.xml and get: Reference inherited.path not found.

If I change build-child.xml to be:

<?xml version="1.0"?>
<project name="child" default="do-child">
    <target name="do-child">
        <pathconvert property="converted.path" refid="inherited.path"/>
    </target>
</project>

It works fine...

Obviously I could work around this in several ways, but I wanted to do this the proper way. What am I doing wrong?

like image 895
krico Avatar asked Nov 26 '25 08:11

krico


1 Answers

This behavior has been encountered before:

Passing References from Master Build File to Child

I couldn't find anything that suggests whether this behavior is by design.

like image 130
Chad Nouis Avatar answered Nov 27 '25 23:11

Chad Nouis