Search in sources :

Example 1 with PlexusContainerException

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

the class MavenEmbedder method findExtensions.

private void findExtensions(MavenProject project) {
    // end copied from DefaultLifecycleExecutor.findExtensions
    ExtensionManager extensionManager = getComponent(ExtensionManager.class);
    for (Object each : project.getBuildExtensions()) {
        try {
            extensionManager.addExtension((Extension) each, project, myLocalRepository);
        } catch (PlexusContainerException e) {
            MavenEmbedderLog.LOG.error(e);
        } catch (ArtifactResolutionException e) {
            MavenEmbedderLog.LOG.error(e);
        } catch (ArtifactNotFoundException e) {
            MavenEmbedderLog.LOG.error(e);
        }
    }
    extensionManager.registerWagons();
    Map handlers = findArtifactTypeHandlers(project);
    getComponent(ArtifactHandlerManager.class).addHandlers(handlers);
}
Also used : PlexusContainerException(org.codehaus.plexus.PlexusContainerException) ExtensionManager(org.apache.maven.extension.ExtensionManager) ArtifactHandlerManager(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager)

Example 2 with PlexusContainerException

use of org.codehaus.plexus.PlexusContainerException 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)

Example 3 with PlexusContainerException

use of org.codehaus.plexus.PlexusContainerException in project archiva by apache.

the class PlexusSisuBridge method initialize.

@PostConstruct
public void initialize() throws PlexusSisuBridgeException {
    DefaultContainerConfiguration conf = new DefaultContainerConfiguration();
    conf.setAutoWiring(containerAutoWiring);
    conf.setClassPathScanning(containerClassPathScanning);
    conf.setComponentVisibility(containerComponentVisibility);
    conf.setContainerConfigurationURL(overridingComponentsXml);
    ClassWorld classWorld = new ClassWorld();
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    containerRealm = new ClassRealm(classWorld, "maven", tccl);
    if (tccl instanceof URLClassLoader) {
        URL[] urls = ((URLClassLoader) tccl).getURLs();
        for (URL url : urls) {
            containerRealm.addURL(url);
        }
    }
    conf.setRealm(containerRealm);
    // conf.setClassWorld( classWorld );
    ClassLoader ori = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(containerRealm);
        plexusContainer = new DefaultPlexusContainer(conf);
    } catch (PlexusContainerException e) {
        throw new PlexusSisuBridgeException(e.getMessage(), e);
    } finally {
        Thread.currentThread().setContextClassLoader(ori);
    }
}
Also used : PlexusContainerException(org.codehaus.plexus.PlexusContainerException) ClassRealm(org.codehaus.plexus.classworlds.realm.ClassRealm) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) ClassWorld(org.codehaus.plexus.classworlds.ClassWorld) URL(java.net.URL) PostConstruct(javax.annotation.PostConstruct)

Example 4 with PlexusContainerException

use of org.codehaus.plexus.PlexusContainerException in project gradle by gradle.

the class AbstractMavenPublishAction method newPlexusContainer.

private PlexusContainer newPlexusContainer(List<File> wagonJars) {
    try {
        ClassWorld world = new ClassWorld("plexus.core", ClassWorld.class.getClassLoader());
        ClassRealm classRealm = new ClassRealm(world, "plexus.core", ClassWorld.class.getClassLoader());
        if (wagonJars != null) {
            for (File jar : wagonJars) {
                classRealm.addURL(jar.toURI().toURL());
            }
        }
        return new DefaultPlexusContainer(new DefaultContainerConfiguration().setRealm(classRealm));
    } catch (PlexusContainerException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    } catch (MalformedURLException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
Also used : PlexusContainerException(org.codehaus.plexus.PlexusContainerException) ClassRealm(org.codehaus.plexus.classworlds.realm.ClassRealm) MalformedURLException(java.net.MalformedURLException) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) ClassWorld(org.codehaus.plexus.classworlds.ClassWorld) File(java.io.File)

Example 5 with PlexusContainerException

use of org.codehaus.plexus.PlexusContainerException in project pom-manipulation-ext by release-engineering.

the class Cli method parseSettings.

private Settings parseSettings(File settings) throws PlexusContainerException, ComponentLookupException, SettingsBuildingException {
    PlexusContainer container = new DefaultPlexusContainer();
    DefaultSettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
    settingsRequest.setUserSettingsFile(settings);
    settingsRequest.setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE);
    settingsRequest.setUserProperties(session.getUserProperties());
    settingsRequest.setSystemProperties(System.getProperties());
    SettingsBuilder settingsBuilder = container.lookup(SettingsBuilder.class);
    SettingsBuildingResult settingsResult = settingsBuilder.build(settingsRequest);
    Settings effectiveSettings = settingsResult.getEffectiveSettings();
    ProfileSelector profileSelector = container.lookup(ProfileSelector.class);
    ProfileActivationContext profileActivationContext = new DefaultProfileActivationContext().setActiveProfileIds(effectiveSettings.getActiveProfiles());
    List<org.apache.maven.model.Profile> modelProfiles = new ArrayList<>();
    for (Profile profile : effectiveSettings.getProfiles()) {
        modelProfiles.add(SettingsUtils.convertFromSettingsProfile(profile));
    }
    List<org.apache.maven.model.Profile> activeModelProfiles = profileSelector.getActiveProfiles(modelProfiles, profileActivationContext, new ModelProblemCollector() {

        @Override
        public void add(ModelProblem.Severity severity, String message, InputLocation location, Exception cause) {
        // do nothing
        }
    });
    List<String> activeProfiles = new ArrayList<>();
    for (org.apache.maven.model.Profile profile : activeModelProfiles) {
        activeProfiles.add(profile.getId());
    }
    effectiveSettings.setActiveProfiles(activeProfiles);
    return effectiveSettings;
}
Also used : InputLocation(org.apache.maven.model.InputLocation) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) SettingsBuildingResult(org.apache.maven.settings.building.SettingsBuildingResult) ArrayList(java.util.ArrayList) Profile(org.apache.maven.settings.Profile) SettingsBuilder(org.apache.maven.settings.building.SettingsBuilder) ModelProblem(org.apache.maven.model.building.ModelProblem) ProfileSelector(org.apache.maven.model.profile.ProfileSelector) Settings(org.apache.maven.settings.Settings) DefaultProfileActivationContext(org.apache.maven.model.profile.DefaultProfileActivationContext) ProfileActivationContext(org.apache.maven.model.profile.ProfileActivationContext) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) PlexusContainerException(org.codehaus.plexus.PlexusContainerException) RestException(org.commonjava.maven.ext.io.rest.exception.RestException) ManipulationException(org.commonjava.maven.ext.common.ManipulationException) ParseException(org.apache.commons.cli.ParseException) SettingsBuildingException(org.apache.maven.settings.building.SettingsBuildingException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) MavenExecutionRequestPopulationException(org.apache.maven.execution.MavenExecutionRequestPopulationException) ModelProblemCollector(org.apache.maven.model.building.ModelProblemCollector) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) DefaultProfileActivationContext(org.apache.maven.model.profile.DefaultProfileActivationContext)

Aggregations

PlexusContainerException (org.codehaus.plexus.PlexusContainerException)7 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)6 File (java.io.File)3 DefaultContainerConfiguration (org.codehaus.plexus.DefaultContainerConfiguration)3 ClassWorld (org.codehaus.plexus.classworlds.ClassWorld)3 ClassRealm (org.codehaus.plexus.classworlds.realm.ClassRealm)3 MavenExecutionRequestPopulationException (org.apache.maven.execution.MavenExecutionRequestPopulationException)2 SettingsBuildingException (org.apache.maven.settings.building.SettingsBuildingException)2 PlexusContainer (org.codehaus.plexus.PlexusContainer)2 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)2 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1 ParseException (org.apache.commons.cli.ParseException)1 ArtifactHandlerManager (org.apache.maven.artifact.handler.manager.ArtifactHandlerManager)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1