Jochen Theodorou wrote: > Hi all, > > Te problem I have is a little complex but I hope you can help me. Groovy > has an ant task to compile groovy classes and a task to use groovy from > within ant see http://groovy.codehaus.org/Groovy+Ant+Task for details. > But in some enviroments such as in maven with certain plugins we have > conflicting jars. I mean jars of a different version than needed by > groovy. For example antlr or asm. > > Our current workaround for the compile task (groovyc) is to fork the VM. > But this can't be the solution? I mean isn't there a possibility to load > a task through a custom classloader? It's no problem for me to write > such a loader, but where to wire it in? I know about the loaderref > attribute, but as far as I understand this attribute is for reusing a > classloader. A normal classloader can't be used since a normal > classloader looks for a class first in the parent and if the parent > knows the conflicting jar/class then we have the same problem as before.
Since you are passing a classpath to the taskdef above, Ant will create a classloader to load this task's classes. What classes this classloader can see will depend on the classloader hierarchy under Maven. I have no idea what that will be. It is possible to specify a reverseloader="true" attribute on an Ant taskdef. It is highly deprecated, unsupported, bad things happen, etc. It will cause the classloader to consult it's jars first, before those of its parent. > > I heard that when you do loaderref="root" in a maven project you get the > ant-loader, but that will be no help if the normal classpath contains a > conflicting jar for another task. Maybe someone can explain me if a > classpath from a taskdef is added to the loader reffered by loaderref. > If so the ant-loader will be polluted too. > No, this does not happen - loaderref and classpath are exclusive, I think. > I am looking for a really easy to use soultion, don't know if it exists. > But maybe you can give some hints as I am really no ant/maven expert. > > If there are significant changes in ant in this area since 1.6.2 > pleasetell me too. If you ahve an idea how to solve that problem in a > completly different way, I would like to hear them. > > btw: of course I know this is no maven list ;) > I presume you've asked the Maven guys about this. I'm not sure what surrounding classloader structure is in place when Ant tasks run in Maven. Good Luck. Conor --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]