Search in sources :

Example 1 with BaseLoggerManager

use of org.codehaus.plexus.logging.BaseLoggerManager in project intellij-community by JetBrains.

the class MavenEmbedder method create.

@NotNull
public static MavenEmbedder create(@NotNull final MavenEmbedderSettings embedderSettings) {
    @NotNull final Logger logger = getLogger(embedderSettings);
    DefaultPlexusContainer container = new DefaultPlexusContainer();
    container.setClassWorld(new ClassWorld("plexus.core", embedderSettings.getClass().getClassLoader()));
    container.setLoggerManager(new BaseLoggerManager() {

        @Override
        protected Logger createLogger(final String s) {
            return logger;
        }
    });
    try {
        container.initialize();
        container.start();
    } catch (PlexusContainerException e) {
        MavenEmbedderLog.LOG.error(e);
        throw new RuntimeException(e);
    }
    final PlexusComponentConfigurator configurator = embedderSettings.getConfigurator();
    if (configurator != null) {
        configurator.configureComponents(container);
    }
    File mavenHome = embedderSettings.getMavenHome();
    if (mavenHome != null) {
        System.setProperty(PROP_MAVEN_HOME, mavenHome.getPath());
    }
    Settings nativeSettings = buildSettings(container, embedderSettings);
    return new MavenEmbedder(container, nativeSettings, logger, embedderSettings);
}
Also used : PlexusContainerException(org.codehaus.plexus.PlexusContainerException) BaseLoggerManager(org.codehaus.plexus.logging.BaseLoggerManager) ClassWorld(org.codehaus.classworlds.ClassWorld) Logger(org.codehaus.plexus.logging.Logger) NotNull(org.jetbrains.annotations.NotNull) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

File (java.io.File)1 ClassWorld (org.codehaus.classworlds.ClassWorld)1 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)1 PlexusContainerException (org.codehaus.plexus.PlexusContainerException)1 BaseLoggerManager (org.codehaus.plexus.logging.BaseLoggerManager)1 Logger (org.codehaus.plexus.logging.Logger)1 NotNull (org.jetbrains.annotations.NotNull)1