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();
}
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();
}
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);
}
}
Aggregations