ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Venkatesh Sangam <vsan...@gmail.com>
Subject antlib classloader issue
Date Thu, 21 Oct 2010 18:37:05 GMT
Hello,

I have the following case that is resulting in classcastexception. Any
suggestion to fix this is really appreciated.

1. I have an ant build file parent.xml that has an antlib entry and also has
usage for the custom tasks defined in the antlib as follows:

      <taskdef resource="myco/anttasks/antlib.xml"
uri="antlib:myco.anttasks" loaderRef="myco.custom.tasks.loader">
         <classpath refid="custom.tasks.class.path"/>
      </taskdef>

     <custom:myCustomTypeDef id="my.task"
xmlns:custom="antlib:myco.anttasks">
      </custom:myCustomTypeDef>

The implementation details of myCustomTypeDef are
in myco/anttasks/antlib.xml

2. I have another ant build file child.xml that imports parent.xml and
defines its own custom tasks. These new custom tasks are an extension to the
tasks already defined in the parent.xml, which means that I need the class
path reference defined in "custom.tasks.class.path"

3. When I execute the new task in child.xml, I get a classcastexception when
referring to myCustomTypeDef. My code does not directly refer
to myCustomTypeDef, but the parent code that I am extending
references myCustomTypeDef.

4. The classes in the myco/anttasks/antlib.xml are loaded by a different
classloader than the taskdef in my child.xml and hence I cannot see that
class.

How do I resolve this issue? I cannot directly modify parent.xml. Only
child.xml is in my control. How do I make sure that the taskdef in child.xml
are loaded by the same classloader loading the implementation defined in
parent antlib.xml


Thanks,
Venkatesh

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message