use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project maven-plugins by apache.
the class AbstractDeployMojo method configureWagon.
/**
* Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
*
* @param wagon
* @param repositoryId
* @param settings
* @param container
* @param log
* @throws TransferFailedException
* @todo Remove when {@link WagonManager#getWagon(Repository) is available}. It's available in Maven 2.0.5.
*/
private static void configureWagon(Wagon wagon, String repositoryId, Settings settings, PlexusContainer container, Log log) throws TransferFailedException {
log.debug(" configureWagon ");
// MSITE-25: Make sure that the server settings are inserted
for (Server server : settings.getServers()) {
String id = server.getId();
log.debug("configureWagon server " + id);
if (id != null && id.equals(repositoryId) && (server.getConfiguration() != null)) {
final PlexusConfiguration plexusConf = new XmlPlexusConfiguration((Xpp3Dom) server.getConfiguration());
ComponentConfigurator componentConfigurator = null;
try {
componentConfigurator = (ComponentConfigurator) container.lookup(ComponentConfigurator.ROLE, "basic");
if (isMaven3OrMore()) {
componentConfigurator.configureComponent(wagon, plexusConf, container.getContainerRealm());
} else {
configureWagonWithMaven2(componentConfigurator, wagon, plexusConf, container);
}
} catch (final ComponentLookupException e) {
throw new TransferFailedException("While configuring wagon for \'" + repositoryId + "\': Unable to lookup wagon configurator." + " Wagon configuration cannot be applied.", e);
} catch (ComponentConfigurationException e) {
throw new TransferFailedException("While configuring wagon for \'" + repositoryId + "\': Unable to apply wagon configuration.", e);
} finally {
if (componentConfigurator != null) {
try {
container.release(componentConfigurator);
} catch (ComponentLifecycleException e) {
log.error("Problem releasing configurator - ignoring: " + e.getMessage());
}
}
}
}
}
}
use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project maven-plugins by apache.
the class AbstractDeployMojo method deploy.
private void deploy(final File directory, final Repository repository) throws MojoExecutionException {
// TODO: work on moving this into the deployer like the other deploy methods
final Wagon wagon = getWagon(repository, wagonManager);
try {
configureWagon(wagon, repository.getId(), settings, container, getLog());
} catch (TransferFailedException e) {
throw new MojoExecutionException("Unable to configure Wagon: '" + repository.getProtocol() + "'", e);
}
try {
final ProxyInfo proxyInfo;
if (!isMaven3OrMore()) {
proxyInfo = getProxyInfo(repository, wagonManager);
} else {
try {
SettingsDecrypter settingsDecrypter = container.lookup(SettingsDecrypter.class);
proxyInfo = getProxy(repository, settingsDecrypter);
} catch (ComponentLookupException cle) {
throw new MojoExecutionException("Unable to lookup SettingsDecrypter: " + cle.getMessage(), cle);
}
}
push(directory, repository, wagon, proxyInfo, getLocales(), getDeployModuleDirectory());
if (chmod) {
chmod(wagon, repository, chmodOptions, chmodMode);
}
} finally {
try {
wagon.disconnect();
} catch (ConnectionException e) {
getLog().error("Error disconnecting wagon - ignored", e);
}
}
}
use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project maven-plugins by apache.
the class DefaultAssemblyArchiver method configureContainerDescriptorHandler.
private void configureContainerDescriptorHandler(final ContainerDescriptorHandler handler, final Xpp3Dom config, final AssemblerConfigurationSource configSource) throws InvalidAssemblerConfigurationException {
getLogger().debug("Configuring handler: '" + handler.getClass().getName() + "' -->");
try {
configureComponent(handler, config, configSource);
} catch (final ComponentConfigurationException e) {
throw new InvalidAssemblerConfigurationException("Failed to configure handler: " + handler.getClass().getName(), e);
} catch (final ComponentLookupException e) {
throw new InvalidAssemblerConfigurationException("Failed to lookup configurator for setup of handler: " + handler.getClass().getName(), e);
}
getLogger().debug("-- end configuration --");
}
use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project intellij-plugins by JetBrains.
the class GeneratorServer method createPlexusContainer.
private static DefaultPlexusContainer createPlexusContainer() throws PlexusContainerException, ComponentLookupException {
ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration().setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true).setClassWorld(new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader())).setName("maven");
final DefaultPlexusContainer container = new DefaultPlexusContainer(containerConfiguration);
final List<LocalRepositoryManagerFactory> factoryList = Collections.singletonList(container.lookup(LocalRepositoryManagerFactory.class, "simple"));
final String mavenVersion = container.lookup(RuntimeInformation.class).getMavenVersion();
// tracked impl is not suitable for us (our list of remote repo may be not equals - we don't want think about it)
if (mavenVersion.length() >= 5 && mavenVersion.charAt(2) == '0' && mavenVersion.charAt(4) < '4') {
final DefaultRepositorySystem repositorySystem = (DefaultRepositorySystem) container.lookup(RepositorySystem.class);
try {
repositorySystem.getClass().getMethod("setLocalRepositoryManagerFactories", List.class).invoke(repositorySystem, factoryList);
} catch (Exception e) {
container.getLoggerManager().getLoggerForComponent(null).warn("", e);
}
} else {
((DefaultLocalRepositoryProvider) container.lookup(LocalRepositoryProvider.class)).setLocalRepositoryManagerFactories(factoryList);
}
return container;
}
use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project che by eclipse.
the class MavenServerImpl method getLifecycleParticipants.
/**
* method from org.apache.maven.DefaultMaven#getLifecycleParticipants
*/
private Collection<AbstractMavenLifecycleParticipant> getLifecycleParticipants(Collection<MavenProject> projects) {
Collection<AbstractMavenLifecycleParticipant> lifecycleListeners = new LinkedHashSet<AbstractMavenLifecycleParticipant>();
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
try {
lifecycleListeners.addAll(container.lookupList(AbstractMavenLifecycleParticipant.class));
} catch (ComponentLookupException e) {
// this is just silly, lookupList should return an empty list!
logWarn("Failed to lookup lifecycle participants: " + e.getMessage());
}
Collection<ClassLoader> scannedRealms = new HashSet<ClassLoader>();
for (MavenProject project : projects) {
ClassLoader projectRealm = project.getClassRealm();
if (projectRealm != null && scannedRealms.add(projectRealm)) {
Thread.currentThread().setContextClassLoader(projectRealm);
try {
lifecycleListeners.addAll(container.lookupList(AbstractMavenLifecycleParticipant.class));
} catch (ComponentLookupException e) {
// this is just silly, lookupList should return an empty list!
logWarn("Failed to lookup lifecycle participants: " + e.getMessage());
}
}
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
return lifecycleListeners;
}
Aggregations