ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murray, Mike" <...@ptc.com>
Subject RE: antlib classloader issue
Date Thu, 04 Nov 2010 03:18:52 GMT
I'm far from an expert in the area of ClassLoaders, but it seems to me
the only solution is to load your tasks with the same loaderRef that is
used by the parent, if you can make no changes to the parent.

-----Original Message-----
From: Venkatesh Sangam [mailto:vsangam@gmail.com] 
Sent: Wednesday, November 03, 2010 11:44 AM
To: user@ant.apache.org
Subject: Re: antlib classloader issue

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

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


Mime
View raw message