Search in sources :

Example 1 with ContainerDescriptorHandlerConfig

use of org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig 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 ContainerDescriptorHandlerConfig

use of org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method testMergeComponentWithAssembly_ShouldAddOneContainerDescriptorHandlerToExistingListOfTwo.

// FIXME: Deep merging should take place...
// public void
// testMergeComponentWithAssembly_ShouldMergeOneFileSetToOneOfExistingTwo()
// {
// Assembly assembly = new Assembly();
//
// FileSet fs = new FileSet();
// fs.setDirectory( "/dir" );
// fs.addInclude( "**/test.txt" );
//
// assembly.addFileSet( fs );
//
// fs = new FileSet();
// fs.setDirectory( "/other-dir" );
// assembly.addFileSet( fs );
//
// fs = new FileSet();
// fs.setDirectory( "/dir" );
// fs.addInclude( "**/components.txt" );
//
// Component component = new Component();
//
// component.addFileSet( fs );
//
// new DefaultAssemblyReader().mergeComponentWithAssembly( component,
// assembly );
//
// List<FileSet> fileSets = assembly.getFileSets();
//
// assertNotNull( fileSets );
// assertEquals( 2, fileSets.size() );
//
// FileSet rfs1 = (FileSet) fileSets.get( 0 );
// assertEquals( "/dir", rfs1.getDirectory() );
//
// List includes = rfs1.getIncludes();
//
// assertNotNull( includes );
// assertEquals( 2, includes.size() );
// assertTrue( includes.contains( "**/test.txt" ) );
// assertTrue( includes.contains( "**/components.txt" ) );
//
// FileSet rfs2 = (FileSet) fileSets.get( 1 );
// assertEquals( "/other-dir", rfs2.getDirectory() );
//
// }
public void testMergeComponentWithAssembly_ShouldAddOneContainerDescriptorHandlerToExistingListOfTwo() {
    final Assembly assembly = new Assembly();
    ContainerDescriptorHandlerConfig cfg = new ContainerDescriptorHandlerConfig();
    cfg.setHandlerName("one");
    assembly.addContainerDescriptorHandler(cfg);
    cfg = new ContainerDescriptorHandlerConfig();
    cfg.setHandlerName("two");
    assembly.addContainerDescriptorHandler(cfg);
    final Component component = new Component();
    cfg = new ContainerDescriptorHandlerConfig();
    cfg.setHandlerName("three");
    component.addContainerDescriptorHandler(cfg);
    new DefaultAssemblyReader().mergeComponentWithAssembly(component, assembly);
    final List<ContainerDescriptorHandlerConfig> result = assembly.getContainerDescriptorHandlers();
    assertNotNull(result);
    assertEquals(3, result.size());
    final Iterator<ContainerDescriptorHandlerConfig> it = result.iterator();
    assertEquals("one", it.next().getHandlerName());
    assertEquals("two", it.next().getHandlerName());
    assertEquals("three", it.next().getHandlerName());
}
Also used : ContainerDescriptorHandlerConfig(org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig) Component(org.apache.maven.plugins.assembly.model.Component) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 3 with ContainerDescriptorHandlerConfig

use of org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig in project maven-plugins by apache.

the class DefaultAssemblyReader method mergeComponentWithAssembly.

/**
     * Add the content of a single Component to main assembly
     *
     * @param component The component
     * @param assembly The assembly
     */
protected void mergeComponentWithAssembly(final Component component, final Assembly assembly) {
    final List<ContainerDescriptorHandlerConfig> containerHandlerDescriptors = component.getContainerDescriptorHandlers();
    for (final ContainerDescriptorHandlerConfig cfg : containerHandlerDescriptors) {
        assembly.addContainerDescriptorHandler(cfg);
    }
    final List<DependencySet> dependencySetList = component.getDependencySets();
    for (final DependencySet dependencySet : dependencySetList) {
        assembly.addDependencySet(dependencySet);
    }
    final List<FileSet> fileSetList = component.getFileSets();
    for (final FileSet fileSet : fileSetList) {
        assembly.addFileSet(fileSet);
    }
    final List<FileItem> fileList = component.getFiles();
    for (final FileItem fileItem : fileList) {
        assembly.addFile(fileItem);
    }
    final List<Repository> repositoriesList = component.getRepositories();
    for (final Repository repository : repositoriesList) {
        assembly.addRepository(repository);
    }
    final List<ModuleSet> moduleSets = component.getModuleSets();
    for (final ModuleSet moduleSet : moduleSets) {
        assembly.addModuleSet(moduleSet);
    }
}
Also used : FileItem(org.apache.maven.plugins.assembly.model.FileItem) Repository(org.apache.maven.plugins.assembly.model.Repository) FileSet(org.apache.maven.plugins.assembly.model.FileSet) ContainerDescriptorHandlerConfig(org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) ModuleSet(org.apache.maven.plugins.assembly.model.ModuleSet)

Aggregations

ContainerDescriptorHandlerConfig (org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig)3 ArrayList (java.util.ArrayList)1 InvalidAssemblerConfigurationException (org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException)1 ComponentsXmlArchiverFileFilter (org.apache.maven.plugins.assembly.filter.ComponentsXmlArchiverFileFilter)1 ContainerDescriptorHandler (org.apache.maven.plugins.assembly.filter.ContainerDescriptorHandler)1 Assembly (org.apache.maven.plugins.assembly.model.Assembly)1 Component (org.apache.maven.plugins.assembly.model.Component)1 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)1 FileItem (org.apache.maven.plugins.assembly.model.FileItem)1 FileSet (org.apache.maven.plugins.assembly.model.FileSet)1 ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)1 Repository (org.apache.maven.plugins.assembly.model.Repository)1