use of org.apache.maven.plugins.assembly.model.FileSet 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);
}
}
use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.
the class FileSetAssemblyPhase method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(@Nonnull final Assembly assembly, final Archiver archiver, final AssemblerConfigurationSource configSource) throws ArchiveCreationException, AssemblyFormattingException {
final List<FileSet> fileSets = assembly.getFileSets();
if ((fileSets != null) && !fileSets.isEmpty()) {
final AddFileSetsTask task = new AddFileSetsTask(fileSets);
task.setLogger(getLogger());
task.execute(archiver, configSource);
}
}
use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.
the class ModuleSetAssemblyPhase method addModuleSourceFileSets.
void addModuleSourceFileSets(final ModuleSources sources, final Set<MavenProject> moduleProjects, final Archiver archiver, final AssemblerConfigurationSource configSource) throws ArchiveCreationException, AssemblyFormattingException {
if (sources == null) {
return;
}
final List<FileSet> fileSets = new ArrayList<FileSet>();
if (isDeprecatedModuleSourcesConfigPresent(sources)) {
final FileSet fs = new FileSet();
fs.setOutputDirectory(sources.getOutputDirectory());
fs.setIncludes(sources.getIncludes());
fs.setExcludes(sources.getExcludes());
fs.setUseDefaultExcludes(sources.isUseDefaultExcludes());
fileSets.add(fs);
}
List<FileSet> subFileSets = sources.getFileSets();
if ((subFileSets == null) || subFileSets.isEmpty()) {
final FileSet fs = new FileSet();
fs.setDirectory("src");
subFileSets = Collections.singletonList(fs);
}
fileSets.addAll(subFileSets);
for (final MavenProject moduleProject : moduleProjects) {
getLogger().info("Processing sources for module project: " + moduleProject.getId());
final List<FileSet> moduleFileSets = new ArrayList<FileSet>();
for (final FileSet fileSet : fileSets) {
moduleFileSets.add(createFileSet(fileSet, sources, moduleProject, configSource));
}
final AddFileSetsTask task = new AddFileSetsTask(moduleFileSets);
task.setProject(moduleProject);
task.setModuleProject(moduleProject);
task.setLogger(getLogger());
task.execute(archiver, configSource);
}
}
use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testMergeComponentWithAssembly_ShouldAddOneFileSetToExistingListOfTwo.
public void testMergeComponentWithAssembly_ShouldAddOneFileSetToExistingListOfTwo() {
final Assembly assembly = new Assembly();
FileSet fs = new FileSet();
fs.setDirectory("/dir");
assembly.addFileSet(fs);
fs = new FileSet();
fs.setDirectory("/other-dir");
assembly.addFileSet(fs);
fs = new FileSet();
fs.setDirectory("/third-dir");
final Component component = new Component();
component.addFileSet(fs);
new DefaultAssemblyReader().mergeComponentWithAssembly(component, assembly);
final List<FileSet> fileSets = assembly.getFileSets();
assertNotNull(fileSets);
assertEquals(3, fileSets.size());
final FileSet rfs1 = fileSets.get(0);
assertEquals("/dir", rfs1.getDirectory());
final FileSet rfs2 = fileSets.get(1);
assertEquals("/other-dir", rfs2.getDirectory());
final FileSet rfs3 = fileSets.get(2);
assertEquals("/third-dir", rfs3.getDirectory());
}
use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testMergeComponentsWithMainAssembly_ShouldAddOneFileSetToAssembly.
public void testMergeComponentsWithMainAssembly_ShouldAddOneFileSetToAssembly() throws IOException, AssemblyReadException {
final Component component = new Component();
final FileSet fileSet = new FileSet();
fileSet.setDirectory("/dir");
component.addFileSet(fileSet);
final File componentFile = fileManager.createTempFile();
Writer writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(componentFile), "UTF-8");
final ComponentXpp3Writer componentWriter = new ComponentXpp3Writer();
componentWriter.write(writer, component);
writer.close();
writer = null;
} finally {
IOUtil.close(writer);
}
final String filename = componentFile.getName();
final Assembly assembly = new Assembly();
assembly.addComponentDescriptor(filename);
final File basedir = componentFile.getParentFile();
final MavenProject project = new MavenProject();
expect(configSource.getProject()).andReturn(project).anyTimes();
expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(configSource);
InterpolationState is = new InterpolationState();
ComponentXpp3Reader.ContentTransformer componentIp = AssemblyInterpolator.componentInterpolator(FixedStringSearchInterpolator.create(), is, new ConsoleLogger(Logger.LEVEL_DEBUG, "console"));
mockManager.replayAll();
new DefaultAssemblyReader().mergeComponentsWithMainAssembly(assembly, null, configSource, componentIp);
final List<FileSet> fileSets = assembly.getFileSets();
assertNotNull(fileSets);
assertEquals(1, fileSets.size());
final FileSet fs = fileSets.get(0);
assertEquals("/dir", fs.getDirectory());
mockManager.verifyAll();
}
Aggregations