Search in sources :

Example 6 with ComponentLookupException

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());
                    }
                }
            }
        }
    }
}
Also used : PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) Server(org.apache.maven.settings.Server) ComponentConfigurator(org.codehaus.plexus.component.configurator.ComponentConfigurator) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) ComponentLifecycleException(org.codehaus.plexus.component.repository.exception.ComponentLifecycleException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) TransferFailedException(org.apache.maven.wagon.TransferFailedException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 7 with ComponentLookupException

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);
        }
    }
}
Also used : ProxyInfo(org.apache.maven.wagon.proxy.ProxyInfo) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) Wagon(org.apache.maven.wagon.Wagon) TransferFailedException(org.apache.maven.wagon.TransferFailedException) ConnectionException(org.apache.maven.wagon.ConnectionException)

Example 8 with ComponentLookupException

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 --");
}
Also used : ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) InvalidAssemblerConfigurationException(org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 9 with ComponentLookupException

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;
}
Also used : DefaultLocalRepositoryProvider(org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider) DefaultRepositorySystem(org.eclipse.aether.internal.impl.DefaultRepositorySystem) ClassWorld(org.codehaus.plexus.classworlds.ClassWorld) SettingsBuildingException(org.apache.maven.settings.building.SettingsBuildingException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) IOException(java.io.IOException) DefaultRepositorySystem(org.eclipse.aether.internal.impl.DefaultRepositorySystem) RepositorySystem(org.apache.maven.repository.RepositorySystem) LocalRepositoryManagerFactory(org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory) DefaultLocalRepositoryProvider(org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider) LocalRepositoryProvider(org.eclipse.aether.impl.LocalRepositoryProvider) RuntimeInformation(org.apache.maven.rtinfo.RuntimeInformation)

Example 10 with ComponentLookupException

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MavenProject(org.apache.maven.project.MavenProject) AbstractMavenLifecycleParticipant(org.apache.maven.AbstractMavenLifecycleParticipant) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)15 ArrayList (java.util.ArrayList)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 IOException (java.io.IOException)3 LinkedHashSet (java.util.LinkedHashSet)3 Artifact (org.apache.maven.artifact.Artifact)3 ArtifactMetadataRetrievalException (org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException)3 ArtifactMetadataSource (org.apache.maven.artifact.metadata.ArtifactMetadataSource)3 ResolutionGroup (org.apache.maven.artifact.metadata.ResolutionGroup)3 ArtifactFilter (org.apache.maven.artifact.resolver.filter.ArtifactFilter)3 DefaultMetadataResolutionRequest (org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest)3 MetadataResolutionRequest (org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest)3 ComponentConfigurationException (org.codehaus.plexus.component.configurator.ComponentConfigurationException)3 LinkedHashMap (java.util.LinkedHashMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 InvalidRepositoryException (org.apache.maven.artifact.InvalidRepositoryException)2 ArtifactNotFoundException (org.apache.maven.artifact.resolver.ArtifactNotFoundException)2 ArtifactResolutionException (org.apache.maven.artifact.resolver.ArtifactResolutionException)2 MavenReport (org.apache.maven.reporting.MavenReport)2 MavenReportExecution (org.apache.maven.reporting.exec.MavenReportExecution)2