Search in sources :

Example 36 with ComponentLookupException

use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project maven-plugins by apache.

the class DefaultAssemblyArchiver method configureArchiver.

private void configureArchiver(final Archiver archiver, final AssemblerConfigurationSource configSource) {
    Xpp3Dom config;
    try {
        config = Xpp3DomBuilder.build(new StringReader(configSource.getArchiverConfig()));
    } catch (final XmlPullParserException e) {
        throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
    } catch (final IOException e) {
        throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
    }
    getLogger().debug("Configuring archiver: '" + archiver.getClass().getName() + "' -->");
    try {
        configureComponent(archiver, config, configSource);
    } catch (final ComponentConfigurationException e) {
        throw new ArchiverException("Failed to configure archiver: " + archiver.getClass().getName(), e);
    } catch (final ComponentLookupException e) {
        throw new ArchiverException("Failed to lookup configurator for setup of archiver: " + archiver.getClass().getName(), e);
    }
    getLogger().debug("-- end configuration --");
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) StringReader(java.io.StringReader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 37 with ComponentLookupException

use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project maven-plugins by apache.

the class PdfMojo method getReports.

protected List<MavenReportExecution> getReports() throws MojoExecutionException {
    if (!isMaven3OrMore()) {
        getLog().error("Report generation is not supported with Maven <= 2.x");
    }
    MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
    mavenReportExecutorRequest.setLocalRepository(localRepository);
    mavenReportExecutorRequest.setMavenSession(session);
    mavenReportExecutorRequest.setProject(project);
    mavenReportExecutorRequest.setReportPlugins(reportingPlugins);
    MavenReportExecutor mavenReportExecutor;
    try {
        mavenReportExecutor = (MavenReportExecutor) container.lookup(MavenReportExecutor.class.getName());
    } catch (ComponentLookupException e) {
        throw new MojoExecutionException("could not get MavenReportExecutor component", e);
    }
    return mavenReportExecutor.buildMavenReports(mavenReportExecutorRequest);
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MavenReportExecutor(org.apache.maven.reporting.exec.MavenReportExecutor) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) MavenReportExecutorRequest(org.apache.maven.reporting.exec.MavenReportExecutorRequest)

Example 38 with ComponentLookupException

use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project maven-plugins by apache.

the class AbstractSiteRenderingMojo method getReports.

protected List<MavenReportExecution> getReports() throws MojoExecutionException {
    List<MavenReportExecution> allReports;
    if (isMaven3OrMore()) {
        // Maven 3
        MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
        mavenReportExecutorRequest.setLocalRepository(localRepository);
        mavenReportExecutorRequest.setMavenSession(mavenSession);
        mavenReportExecutorRequest.setProject(project);
        mavenReportExecutorRequest.setReportPlugins(reportingPlugins);
        MavenReportExecutor mavenReportExecutor;
        try {
            mavenReportExecutor = (MavenReportExecutor) container.lookup(MavenReportExecutor.class.getName());
        } catch (ComponentLookupException e) {
            throw new MojoExecutionException("could not get MavenReportExecutor component", e);
        }
        allReports = mavenReportExecutor.buildMavenReports(mavenReportExecutorRequest);
    } else {
        // Maven 2
        allReports = new ArrayList<MavenReportExecution>(reports.size());
        for (MavenReport report : reports) {
            allReports.add(new MavenReportExecution(report));
        }
    }
    // filter out reports that can't be generated
    List<MavenReportExecution> reportExecutions = new ArrayList<MavenReportExecution>(allReports.size());
    for (MavenReportExecution exec : allReports) {
        if (exec.canGenerateReport()) {
            reportExecutions.add(exec);
        }
    }
    return reportExecutions;
}
Also used : MavenReportExecution(org.apache.maven.reporting.exec.MavenReportExecution) MavenReport(org.apache.maven.reporting.MavenReport) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArrayList(java.util.ArrayList) MavenReportExecutor(org.apache.maven.reporting.exec.MavenReportExecutor) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) MavenReportExecutorRequest(org.apache.maven.reporting.exec.MavenReportExecutorRequest)

Example 39 with ComponentLookupException

use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project tycho by eclipse.

the class UpdateSiteAssembler method packDir.

private void packDir(File sourceDir, File targetZip) {
    ZipArchiver archiver;
    try {
        archiver = (ZipArchiver) session.lookup(ZipArchiver.ROLE, "zip");
    } catch (ComponentLookupException e) {
        throw new RuntimeException("Unable to resolve ZipArchiver", e);
    }
    archiver.setDestFile(targetZip);
    try {
        archiver.addDirectory(sourceDir);
        archiver.createArchive();
    } catch (IOException e) {
        throw new RuntimeException("Error packing zip", e);
    } catch (ArchiverException e) {
        throw new RuntimeException("Error packing zip", e);
    }
}
Also used : ZipArchiver(org.codehaus.plexus.archiver.zip.ZipArchiver) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException)

Example 40 with ComponentLookupException

use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project karaf by apache.

the class DependencyHelperFactory method createDependencyHelper.

/**
 * Create a new {@link DependencyHelper} based on what has been found in
 * {@link org.codehaus.plexus.PlexusContainer}.
 *
 * @param container    The Maven Plexus container to use.
 * @param mavenProject The Maven project to use.
 * @param mavenSession The Maven session.
 * @param cacheSize    Size of the artifact/file LRU cache
 * @param log          The log to use for the messages.
 *
 * @return The {@link DependencyHelper} depending of the Maven version used.
 *
 * @throws MojoExecutionException If the plugin execution fails.
 */
public static DependencyHelper createDependencyHelper(PlexusContainer container, MavenProject mavenProject, MavenSession mavenSession, int cacheSize, Log log) throws MojoExecutionException {
    try {
        final RepositorySystem system = container.lookup(RepositorySystem.class);
        final RepositorySystemSession session = mavenSession.getRepositorySession();
        final List<RemoteRepository> repositories = mavenProject.getRemoteProjectRepositories();
        return new Dependency31Helper(repositories, session, system, cacheSize);
    } catch (ComponentLookupException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}
Also used : RepositorySystem(org.eclipse.aether.RepositorySystem) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException)

Aggregations

ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)40 IOException (java.io.IOException)11 ServerException (com.ctrip.xpipe.redis.console.exception.ServerException)7 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)7 ArrayList (java.util.ArrayList)6 PostConstruct (javax.annotation.PostConstruct)6 File (java.io.File)5 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)5 Artifact (org.apache.maven.artifact.Artifact)4 ArtifactFilter (org.apache.maven.artifact.resolver.filter.ArtifactFilter)4 MavenSession (org.apache.maven.execution.MavenSession)4 SettingsBuildingException (org.apache.maven.settings.building.SettingsBuildingException)4 LinkedHashMap (java.util.LinkedHashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 InvalidRepositoryException (org.apache.maven.artifact.InvalidRepositoryException)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 DefaultMetadataResolutionRequest (org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest)3 MetadataResolutionRequest (org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest)3