ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Extending path
Date Mon, 14 Jun 2010 09:06:15 GMT
On 2010-06-11, Jon Stevens wrote:

> Ok, new question. Say I have a build.xml that looks like this:

> <project>
>     <spath id="filelist.classpath" scope="unit">
>         <sfilelist dir="${lib.dir}">
>             <sfile name="${ant.jar}" scope="compile" />
>             <sfile name="${ant-googlecode.jar}" scope="runtime" />
>             <sfile name="svntask.jar" scope="runtime" />
>         </sfilelist>
>         <sfilelist dir="${target.dir}">
>             <sfile name="sweetened.jar" src="src" scope="runtime" />
>         </sfilelist>
>         <sfilelist dir="${alexandria.dir}">
>             <sfile name="${junit.jar}" scope="unit" />
>         </sfilelist>
>     </spath>

>     <spath id="javac.classpath" scope="compile" refid="filelist.classpath" />

>     <echo>
>         javac.classpath: ${toString:javac.classpath}
>     </echo>
> </project>

> spath extends Union.

> When the ${toString} is called, the spath.getCollection() method is
> called by ant. At that point, though, ant is calling the
> getCollection() method on the spath instance of filelist.classpath

I think it is this code in BaseResourceCollectionContainer that is
causing the problem for you

    public final synchronized Iterator iterator() {
        if (isReference()) {
            return ((BaseResourceCollectionContainer) getCheckedRef()).iterator();
        }

Since you spath is a reference (the refid syntax) the iterator() method
just delegates to the "real" instance.  Since that method is final (at
least in 1.8.0) you can't even override it.

> I guess one option would be to implement my own refid type system
> within my spath, but I was hoping that I could just use ant's.

You don't really want to use refid because this is meant to say a given
type is just a placeholder for something defined anywhere else.  In your
case you just need to use a different name for the attribute (say
reference instead of refid) and just use Ant's reference system for all
the rest - don't make your baseclass think the instance was just a
placeholder.

Stefan

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


Mime
View raw message