Fixed MNG-908: set the contextClassLoader to the classrealm of the

currently executing plugin, so that both getClass().getClassLoader()
and Thread.currentThread().getContextClassLoader() return the same
classloader (and hence resources).



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@290040 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Kenney Westerhof 2005-09-19 01:29:18 +00:00
parent 12916488b4
commit 7009b9e799
2 changed files with 14 additions and 0 deletions

View File

@ -352,8 +352,13 @@ public class DefaultPluginManager
dispatcher.dispatchStart( event, goalExecId );
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
try
{
Thread.currentThread().setContextClassLoader(
mojoDescriptor.getPluginDescriptor().getClassRealm().getClassLoader() );
plugin.execute();
dispatcher.dispatchEnd( event, goalExecId );
@ -366,6 +371,9 @@ public class DefaultPluginManager
}
finally
{
Thread.currentThread().setContextClassLoader( oldClassLoader );
try
{
PlexusContainer pluginContainer = getPluginContainer( mojoDescriptor.getPluginDescriptor() );

View File

@ -302,4 +302,10 @@ public class PluginDescriptor
{
this.classRealm = classRealm;
}
public ClassRealm getClassRealm()
{
return classRealm;
}
}