I sent this email to the user list a few days back and haven't heard
anything yet. Since the question is about a code problem in the ant, I
thought I might have better luck in here. I would really appreciate
any help on this, as my entire build process is based on this
approach, and I don't want to workaround using external tools, custom
tasks etc.

I also found later that this is not specific to FileSet inside a
MacroDef. I commented the calls to let the build go past that, and got
a CCE for a macro that was invoking another macro in the sequence. I
think there is a more generic problem here, as testing these macros in
a completely isolated environment shows no problems. The build scripts
loads and depends on a whole bunch of external files, so there is no
use sending the entire file, but if anyone thinks they can give better
help by looking at the whole file, please let me know and I will do
something.

Thank you,
Hari

-----------

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="[EMAIL PROTECTED]" 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to