mirror of https://github.com/apache/maven.git
[MNG-5019] [regression] String-based component lookups performed by report mojos fail with ClassCastException
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1074184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3279b97102
commit
b6ee02c3df
|
@ -24,7 +24,6 @@ import org.apache.maven.model.Plugin;
|
|||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
@ -39,9 +38,6 @@ public class DefaultBuildPluginManager
|
|||
implements BuildPluginManager
|
||||
{
|
||||
|
||||
@Requirement
|
||||
private PlexusContainer container;
|
||||
|
||||
@Requirement
|
||||
private MavenPluginManager mavenPluginManager;
|
||||
|
||||
|
@ -86,8 +82,6 @@ public class DefaultBuildPluginManager
|
|||
throw new PluginExecutionException( mojoExecution, project, e );
|
||||
}
|
||||
|
||||
ClassRealm oldLookupRealm = container.setLookupRealm( pluginRealm );
|
||||
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader( pluginRealm );
|
||||
|
||||
|
@ -159,7 +153,6 @@ public class DefaultBuildPluginManager
|
|||
mavenPluginManager.releaseMojo( mojo, mojoExecution );
|
||||
|
||||
Thread.currentThread().setContextClassLoader( oldClassLoader );
|
||||
container.setLookupRealm( oldLookupRealm );
|
||||
|
||||
legacySupport.setSession( oldSession );
|
||||
}
|
||||
|
|
|
@ -109,16 +109,16 @@ public class DefaultPluginManager
|
|||
throw new PluginManagerException( plugin, e.getMessage(), e );
|
||||
}
|
||||
|
||||
ClassRealm oldRealm = container.getLookupRealm();
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
try
|
||||
{
|
||||
container.setLookupRealm( pluginDescriptor.getClassRealm() );
|
||||
Thread.currentThread().setContextClassLoader( pluginDescriptor.getClassRealm() );
|
||||
|
||||
return container.lookup( role, roleHint );
|
||||
}
|
||||
finally
|
||||
{
|
||||
container.setLookupRealm( oldRealm );
|
||||
Thread.currentThread().setContextClassLoader( oldClassLoader );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,16 +141,16 @@ public class DefaultPluginManager
|
|||
throw new PluginManagerException( plugin, e.getMessage(), e );
|
||||
}
|
||||
|
||||
ClassRealm oldRealm = container.getLookupRealm();
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
try
|
||||
{
|
||||
container.setLookupRealm( pluginDescriptor.getClassRealm() );
|
||||
Thread.currentThread().setContextClassLoader( pluginDescriptor.getClassRealm() );
|
||||
|
||||
return container.lookupMap( role );
|
||||
}
|
||||
finally
|
||||
{
|
||||
container.setLookupRealm( oldRealm );
|
||||
Thread.currentThread().setContextClassLoader( oldClassLoader );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -374,6 +374,9 @@ public class MavenCli
|
|||
|
||||
container = new DefaultPlexusContainer( cc );
|
||||
|
||||
// NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups
|
||||
container.setLookupRealm( null );
|
||||
|
||||
container.setLoggerManager( new MavenLoggerManager( logger ) );
|
||||
|
||||
customizeContainer( container );
|
||||
|
|
Loading…
Reference in New Issue