I'm not 100% sure this is a bug, or just a known limitation of <xmlproperty>, but I'll give it a go and see what others think (I'm using Ant-1.6.2, btw)...


When I use <xmlproperty> to define a path and include a reference to a path that I override later, if that overridden path includes a pathelement using a property that hadn't yet been resolved by <xmlproperty> at the time it loaded, the path won't be resolved properly. If, instead, I put the path definition directly in the build.xml file, it resolves fine even though, in both cases, the property used in the pathelement defintion is defined after the original path was defined. Here's the relevant "ant -verbose" output...

parsing buildfile D:\dev\test\build.xml with URI = file:///D:/dev/test/build.xml
Project base dir set to: D:\dev\test
[xmlproperty] Loading D:\dev\test\props.xml
Property ${classesdir.local} has not been set
Overriding previous definition of reference to build.classpath.local


Obviously, my compile fails since the classpath isn't properly set.


props.xml looks like...

<root-tag>
    <path pathid="build.classpath">
        <path refid="build.classpath.local"/>
    </path>
</root-tag>

build.xml looks like...

<project name="hmmm" default="compile" basedir=".">

    <property name="srcdir"     location="src"/>
    <property name="classesdir" location="classes"/>
    <xmlproperty
        file="props.xml"
        collapseAttributes="true"
        keepRoot="false"
        semanticAttributes="true"/>

    <!--path id="build.classpath">
        <path refid="build.classpath.local"/>
    </path-->

    <property name="srcdir.local"     location="local-src"/>
    <property name="classesdir.local" location="local-classes"/>

    <path id="build.classpath.local">
        <pathelement location="${classesdir.local}" />
    </path>

    <target name="clean">
        <delete dir="${classesdir}"/>
        <delete dir="${classesdir.local}"/>
    </target>

<target name="compile">
<mkdir dir="${classesdir}"/>
<mkdir dir="${classesdir.local}"/>
<!-- srcdir depends on srcdir.local, so this order is important! -->
<javac srcdir="${srcdir.local}" destdir="${classesdir.local}" includeAntRuntime="false"/>
<javac srcdir="${srcdir}" destdir="${classesdir}" includeAntRuntime="false" classpathref="build.classpath"/>
</target>


</project>

Try commenting out <xmlproperty> and uncommenting the commented out <path> to see how it works when the path is included directly in the build file rather than in <xmlproperty>..

Is this a bug or a known limitation of defining paths in <xmlproperty>? BTW, the way to work around this is to define the "classesdir.local" property before (or inside) <xmlproperty> or hard code the path information rather than using a property. However, this is kind of annoying because this should be transparent to the build file writer. Either both cases should work or both should fail. My assertion is that they both should work. Am I right?

Jake


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to