ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hari Krishna Dara" <harid...@gmail.com>
Subject FileSet inside MacroDef causing ClassCastException
Date Fri, 11 Aug 2006 22:58:17 GMT
Inside a MacroDef, I am using a FileSet with an id that I refer to
later in the same macro. This is working fine in one of the macros but
the other one causes a CCE at the below line in MacroInstance.copy():

            UnknownElement unknownElement = (UnknownElement) r.getProxy();

While debugging the working case, I observed that the FileSet
correctly shows up as UnknownElement with a wrapper that proxies the
FileSet object, but when it results in CCE, the r.getProxy() returns
the FileSet object itself, instead of an UnknownElement. I don't know
what is causing this to happen though. I am using 1.6.2, but tried
1.6.5 as well and saw the same exception. I tried to reproduce the
problem by copying these two macros into a standalone build file with
some minor modifications to remove the dependency on properties etc.,
and strangely it works fine.

Can anyone provide any help in working around or fixing this problem?
I wanted to try creating the FileSet inside a script task (thus
avoiding the copy() seeing it), but I didn't find anyway to access the
selection element that is being passed into the macro. Can anyone
point me to the API to do this? Unlike the attributes, we can't inline
the element inside a script. An ant eval() would serve a good purpose
though as I can then do project.eval("<selection/>").

Here is the macro that causes trouble (I stripped the sequence to the
least that causes theis problem, but as I said before, I couldn't copy
this into a standalone build file and reproduce the exception):

    <macrodef name="patchifmatches">
        <attribute name="source"/>
        <!-- See "target" on patchif -->
        <attribute name="target"/>
        <attribute name="windows" default="true"/>
        <attribute name="solaris" default="true"/>
        <element name="selection" implicit="true"/>
        <sequential>
            <fileset id="patchfileset" dir="${branch.path}">
                <patternset refid="patch.filelist"/>
                <selection/>
            </fileset>
        </sequential>
    </macrodef>

Here is the macro that is part of the same build file and works fine:

    <macrodef name="checkIfComponentNeedsPatch">
        <attribute name="componentName"/>
        <element name="selection" implicit="true"/>
        <sequential>
            <!-- FIXME: How do I suppress the "override" warning
message this generates -->
            <fileset id="patchfileset" dir="${branch.path}">
                <patternset refid="patch.filelist"/>
                <selection/>
            </fileset>
            <pathconvert pathsep=" " property="@{componentName}NeedsPatchTmp"
                refid="patchfileset"/>
            <condition property="@{componentName}NeedsPatch">
                <not>
                    <equals arg1="${@{componentName}NeedsPatchTmp}" arg2=""/>
                </not>
            </condition>
        </sequential>
    </macrodef>

Here is the stacktrace that I got using the -d option:

C:\dev\puno\scripts\triage\patchbuild.xml:606: java.lang.ClassCastException
        at org.apache.tools.ant.Task.perform(Task.java:373)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:40)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
        at org.apache.tools.ant.Main.runBuild(Main.java:668)
        at org.apache.tools.ant.Main.startAnt(Main.java:187)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.lang.ClassCastException
        at org.apache.tools.ant.taskdefs.MacroInstance.copy(MacroInstance.java:2
73)
        at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
a:375)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        ... 10 more
--- Nested Exception ---
java.lang.ClassCastException
        at org.apache.tools.ant.taskdefs.MacroInstance.copy(MacroInstance.java:2
73)
        at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
a:375)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:40)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
        at org.apache.tools.ant.Main.runBuild(Main.java:668)
        at org.apache.tools.ant.Main.startAnt(Main.java:187)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

Thank you,
Hari

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


Mime
View raw message