if ( cliRequest.classWorld == null )
{
cliRequest.classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() );
}
DefaultPlexusContainer container = this.container;
if ( container == null )
{
logger = setupLogger( cliRequest );
ContainerConfiguration cc = new DefaultContainerConfiguration()
.setClassWorld( cliRequest.classWorld )
.setRealm( setupContainerRealm( cliRequest ) )
.setName( "maven" );
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 );
if ( cliRequest.classWorld == classWorld )
{
this.container = container;
}
}
container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() );
Thread.currentThread().setContextClassLoader( container.getContainerRealm() );
eventSpyDispatcher = container.lookup( EventSpyDispatcher.class );
DefaultEventSpyContext eventSpyContext = new DefaultEventSpyContext();
Map<String, Object> data = eventSpyContext.getData();
data.put( "plexus", container );
data.put( "workingDirectory", cliRequest.workingDirectory );
data.put( "systemProperties", cliRequest.systemProperties );
data.put( "userProperties", cliRequest.userProperties );
data.put( "versionProperties", CLIReportingUtils.getBuildProperties() );
eventSpyDispatcher.init( eventSpyContext );
// refresh logger in case container got customized by spy
logger = container.getLoggerManager().getLoggerForComponent( MavenCli.class.getName(), null );
maven = container.lookup( Maven.class );
executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class );
modelProcessor = createModelProcessor( container );
settingsBuilder = container.lookup( SettingsBuilder.class );
dispatcher = (DefaultSecDispatcher) container.lookup( SecDispatcher.class, "maven" );
}