Search in sources :

Example 1 with ContainerDescriptorHandler

use of org.apache.maven.plugins.assembly.filter.ContainerDescriptorHandler in project maven-plugins by apache.

the class DefaultAssemblyArchiver method selectContainerDescriptorHandlers.

// CHECKSTYLE_OFF: LineLength
private List<ContainerDescriptorHandler> selectContainerDescriptorHandlers(List<ContainerDescriptorHandlerConfig> requestedContainerDescriptorHandlers, final AssemblerConfigurationSource configSource) throws InvalidAssemblerConfigurationException // CHECKSTYLE_ON: LineLength
{
    getLogger().debug("All known ContainerDescriptorHandler components: " + (containerDescriptorHandlers == null ? "none; map is null." : "" + containerDescriptorHandlers.keySet()));
    if (requestedContainerDescriptorHandlers == null) {
        requestedContainerDescriptorHandlers = new ArrayList<ContainerDescriptorHandlerConfig>();
    }
    final List<ContainerDescriptorHandler> handlers = new ArrayList<ContainerDescriptorHandler>();
    final List<String> hints = new ArrayList<String>();
    if (!requestedContainerDescriptorHandlers.isEmpty()) {
        for (final ContainerDescriptorHandlerConfig config : requestedContainerDescriptorHandlers) {
            final String hint = config.getHandlerName();
            final ContainerDescriptorHandler handler = containerDescriptorHandlers.get(hint);
            if (handler == null) {
                throw new InvalidAssemblerConfigurationException("Cannot find ContainerDescriptorHandler with hint: " + hint);
            }
            getLogger().debug("Found container descriptor handler with hint: " + hint + " (component: " + handler + ")");
            if (config.getConfiguration() != null) {
                getLogger().debug("Configuring handler with:\n\n" + config.getConfiguration() + "\n\n");
                configureContainerDescriptorHandler(handler, (Xpp3Dom) config.getConfiguration(), configSource);
            }
            handlers.add(handler);
            hints.add(hint);
        }
    }
    if (!hints.contains("plexus")) {
        handlers.add(new ComponentsXmlArchiverFileFilter());
    }
    return handlers;
}
Also used : ContainerDescriptorHandler(org.apache.maven.plugins.assembly.filter.ContainerDescriptorHandler) ContainerDescriptorHandlerConfig(org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig) ArrayList(java.util.ArrayList) ComponentsXmlArchiverFileFilter(org.apache.maven.plugins.assembly.filter.ComponentsXmlArchiverFileFilter) InvalidAssemblerConfigurationException(org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException)

Example 2 with ContainerDescriptorHandler

use of org.apache.maven.plugins.assembly.filter.ContainerDescriptorHandler in project maven-plugins by apache.

the class DefaultAssemblyArchiver method createArchive.

/**
     * {@inheritDoc}
     */
@Override
public File createArchive(final Assembly assembly, final String fullName, final String format, final AssemblerConfigurationSource configSource, boolean recompressZippedFiles, String mergeManifestMode) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
    validate(assembly);
    String filename = fullName;
    if (!configSource.isIgnoreDirFormatExtensions() || !format.startsWith("dir")) {
        filename += "." + format;
    }
    AssemblyFileUtils.verifyTempDirectoryAvailability(configSource.getTemporaryRootDirectory());
    final File outputDirectory = configSource.getOutputDirectory();
    final File destFile = new File(outputDirectory, filename);
    try {
        final String finalName = configSource.getFinalName();
        final String specifiedBasedir = assembly.getBaseDirectory();
        String basedir = finalName;
        if (specifiedBasedir != null) {
            basedir = AssemblyFormatUtils.getOutputDirectory(specifiedBasedir, finalName, configSource, AssemblyFormatUtils.moduleProjectInterpolator(configSource.getProject()), AssemblyFormatUtils.artifactProjectInterpolator(null));
        }
        final List<ContainerDescriptorHandler> containerHandlers = selectContainerDescriptorHandlers(assembly.getContainerDescriptorHandlers(), configSource);
        final Archiver archiver = createArchiver(format, assembly.isIncludeBaseDirectory(), basedir, configSource, containerHandlers, recompressZippedFiles, mergeManifestMode);
        archiver.setDestFile(destFile);
        for (AssemblyArchiverPhase phase : sortedPhases()) {
            phase.execute(assembly, archiver, configSource);
        }
        archiver.createArchive();
    } catch (final ArchiverException e) {
        throw new ArchiveCreationException("Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e);
    } catch (final IOException e) {
        throw new ArchiveCreationException("Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e);
    } catch (final NoSuchArchiverException e) {
        throw new ArchiveCreationException("Unable to obtain archiver for extension '" + format + "', for assembly: '" + assembly.getId() + "'", e);
    } catch (final DependencyResolutionException e) {
        throw new ArchiveCreationException("Unable to resolve dependencies for assembly '" + assembly.getId() + "'", e);
    }
    return destFile;
}
Also used : ContainerDescriptorHandler(org.apache.maven.plugins.assembly.filter.ContainerDescriptorHandler) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) DependencyResolutionException(org.apache.maven.plugins.assembly.artifact.DependencyResolutionException) IOException(java.io.IOException) File(java.io.File) AssemblyProxyArchiver(org.apache.maven.plugins.assembly.archive.archiver.AssemblyProxyArchiver) AbstractZipArchiver(org.codehaus.plexus.archiver.zip.AbstractZipArchiver) JarArchiver(org.codehaus.plexus.archiver.jar.JarArchiver) TarArchiver(org.codehaus.plexus.archiver.tar.TarArchiver) Archiver(org.codehaus.plexus.archiver.Archiver) DryRunArchiver(org.codehaus.plexus.archiver.diags.DryRunArchiver) WarArchiver(org.codehaus.plexus.archiver.war.WarArchiver) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) AssemblyArchiverPhase(org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase)

Aggregations

ContainerDescriptorHandler (org.apache.maven.plugins.assembly.filter.ContainerDescriptorHandler)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 InvalidAssemblerConfigurationException (org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException)1 AssemblyProxyArchiver (org.apache.maven.plugins.assembly.archive.archiver.AssemblyProxyArchiver)1 AssemblyArchiverPhase (org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase)1 DependencyResolutionException (org.apache.maven.plugins.assembly.artifact.DependencyResolutionException)1 ComponentsXmlArchiverFileFilter (org.apache.maven.plugins.assembly.filter.ComponentsXmlArchiverFileFilter)1 ContainerDescriptorHandlerConfig (org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig)1 Archiver (org.codehaus.plexus.archiver.Archiver)1 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)1 DryRunArchiver (org.codehaus.plexus.archiver.diags.DryRunArchiver)1 JarArchiver (org.codehaus.plexus.archiver.jar.JarArchiver)1 NoSuchArchiverException (org.codehaus.plexus.archiver.manager.NoSuchArchiverException)1 TarArchiver (org.codehaus.plexus.archiver.tar.TarArchiver)1 WarArchiver (org.codehaus.plexus.archiver.war.WarArchiver)1 AbstractZipArchiver (org.codehaus.plexus.archiver.zip.AbstractZipArchiver)1