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);
}
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);
}
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);
}
}
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);
}
}
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;
}
Aggregations