Search in sources :

Example 6 with FileItem

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

the class FileItemAssemblyPhaseTest method testExecute_ShouldAddAbsoluteFileNoFilterNoLineEndingConversion.

public void testExecute_ShouldAddAbsoluteFileNoFilterNoLineEndingConversion() throws ArchiveCreationException, AssemblyFormattingException, IOException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
    final File basedir = fileManager.createTempDir();
    final File file = fileManager.createFile(basedir, "file.txt", "This is a test file.");
    macCS.expectGetBasedir(basedir);
    macCS.expectGetProject(new MavenProject(new Model()));
    macCS.expectGetFinalName("final-name");
    macCS.expectInterpolators();
    final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
    final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    final FileItem fi = new FileItem();
    fi.setSource(file.getAbsolutePath());
    fi.setFiltered(false);
    fi.setLineEnding("keep");
    fi.setFileMode("777");
    macArchiver.expectAddFile(file, "file.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    assembly.addFile(fi);
    mm.replayAll();
    createPhase(macLogger.logger).execute(assembly, macArchiver.archiver, macCS.configSource);
    mm.verifyAll();
}
Also used : FileItem(org.apache.maven.plugins.assembly.model.FileItem) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 7 with FileItem

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

the class FileItemAssemblyPhaseTest method testExecute_WithOutputDirectoryAndDestNameAndIncludeBaseDirectoryFalse.

public void testExecute_WithOutputDirectoryAndDestNameAndIncludeBaseDirectoryFalse() throws Exception {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
    final File basedir = fileManager.createTempDir();
    final File readmeFile = fileManager.createFile(basedir, "README.txt", "This is a test file for README.txt.");
    final File licenseFile = fileManager.createFile(basedir, "LICENSE.txt", "This is a test file for LICENSE.txt.");
    final File configFile = fileManager.createFile(basedir, "config/config.txt", "This is a test file for config/config.txt");
    macCS.expectGetBasedir(basedir);
    macCS.expectGetProject(new MavenProject(new Model()));
    macCS.expectGetFinalName("final-name");
    macCS.expectInterpolators();
    final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
    final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    assembly.setIncludeBaseDirectory(false);
    final FileItem readmeFileItem = new FileItem();
    readmeFileItem.setSource("README.txt");
    readmeFileItem.setDestName("README_renamed.txt");
    readmeFileItem.setFiltered(false);
    readmeFileItem.setLineEnding("keep");
    readmeFileItem.setFileMode("777");
    final FileItem licenseFileItem = new FileItem();
    licenseFileItem.setSource("LICENSE.txt");
    licenseFileItem.setDestName("LICENSE_renamed.txt");
    licenseFileItem.setFiltered(false);
    licenseFileItem.setLineEnding("keep");
    licenseFileItem.setFileMode("777");
    final FileItem configFileItem = new FileItem();
    configFileItem.setSource("config/config.txt");
    configFileItem.setDestName("config_renamed.txt");
    configFileItem.setOutputDirectory("config");
    configFileItem.setFiltered(false);
    configFileItem.setLineEnding("keep");
    configFileItem.setFileMode("777");
    macArchiver.expectAddFile(readmeFile, "README_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    macArchiver.expectAddFile(licenseFile, "LICENSE_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    macArchiver.expectAddFile(configFile, "config/config_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    assembly.addFile(readmeFileItem);
    assembly.addFile(licenseFileItem);
    assembly.addFile(configFileItem);
    mm.replayAll();
    createPhase(macLogger.logger).execute(assembly, macArchiver.archiver, macCS.configSource);
    mm.verifyAll();
}
Also used : FileItem(org.apache.maven.plugins.assembly.model.FileItem) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 8 with FileItem

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

FileItem (org.apache.maven.plugins.assembly.model.FileItem)8 File (java.io.File)6 Assembly (org.apache.maven.plugins.assembly.model.Assembly)6 Model (org.apache.maven.model.Model)5 MavenProject (org.apache.maven.project.MavenProject)5 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)5 EasyMockSupport (org.easymock.classextension.EasyMockSupport)5 IOException (java.io.IOException)1 ArchiveCreationException (org.apache.maven.plugins.assembly.archive.ArchiveCreationException)1 Component (org.apache.maven.plugins.assembly.model.Component)1 ContainerDescriptorHandlerConfig (org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig)1 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)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 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)1 InputStreamTransformer (org.codehaus.plexus.components.io.functions.InputStreamTransformer)1 PlexusIoResource (org.codehaus.plexus.components.io.resources.PlexusIoResource)1