Search in sources :

Example 1 with NoSuchRealmException

use of org.codehaus.plexus.classworlds.realm.NoSuchRealmException in project sts4 by spring-projects.

the class MavenBridge method newPlexusContainer.

private static DefaultPlexusContainer newPlexusContainer() throws PlexusContainerException {
    final ClassWorld classWorld = new ClassWorld(MAVEN_CORE_REALM_ID, ClassWorld.class.getClassLoader());
    final ClassRealm realm;
    try {
        realm = classWorld.getRealm(MAVEN_CORE_REALM_ID);
    } catch (NoSuchRealmException e) {
        throw new PlexusContainerException("Could not lookup required class realm", e);
    }
    final ContainerConfiguration mavenCoreCC = // 
    new DefaultContainerConfiguration().setClassWorld(// 
    classWorld).setRealm(// 
    realm).setClassPathScanning(// 
    PlexusConstants.SCANNING_INDEX).setAutoWiring(// 
    true).setName(// $NON-NLS-1$
    "mavenCore");
    final Module logginModule = new AbstractModule() {

        protected void configure() {
            bind(ILoggerFactory.class).toInstance(LoggerFactory.getILoggerFactory());
        }
    };
    final Module coreExportsModule = new AbstractModule() {

        protected void configure() {
            ClassRealm realm = mavenCoreCC.getRealm();
            CoreExtensionEntry entry = CoreExtensionEntry.discoverFrom(realm);
            CoreExports exports = new CoreExports(entry);
            bind(CoreExports.class).toInstance(exports);
        }
    };
    return new DefaultPlexusContainer(mavenCoreCC, logginModule, coreExportsModule);
}
Also used : NoSuchRealmException(org.codehaus.plexus.classworlds.realm.NoSuchRealmException) PlexusContainerException(org.codehaus.plexus.PlexusContainerException) ClassRealm(org.codehaus.plexus.classworlds.realm.ClassRealm) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) ILoggerFactory(org.slf4j.ILoggerFactory) CoreExports(org.apache.maven.extension.internal.CoreExports) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) CoreExtensionEntry(org.apache.maven.extension.internal.CoreExtensionEntry) ClassWorld(org.codehaus.plexus.classworlds.ClassWorld) Module(com.google.inject.Module) AbstractModule(com.google.inject.AbstractModule) ContainerConfiguration(org.codehaus.plexus.ContainerConfiguration) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) AbstractModule(com.google.inject.AbstractModule)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 CoreExports (org.apache.maven.extension.internal.CoreExports)1 CoreExtensionEntry (org.apache.maven.extension.internal.CoreExtensionEntry)1 ContainerConfiguration (org.codehaus.plexus.ContainerConfiguration)1 DefaultContainerConfiguration (org.codehaus.plexus.DefaultContainerConfiguration)1 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)1 PlexusContainerException (org.codehaus.plexus.PlexusContainerException)1 ClassWorld (org.codehaus.plexus.classworlds.ClassWorld)1 ClassRealm (org.codehaus.plexus.classworlds.realm.ClassRealm)1 NoSuchRealmException (org.codehaus.plexus.classworlds.realm.NoSuchRealmException)1 ILoggerFactory (org.slf4j.ILoggerFactory)1