use of org.apache.maven.plugins.assembly.archive.task.AddDependencySetsTask in project maven-plugins by apache.
the class DependencySetAssemblyPhase method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final Assembly assembly, final Archiver archiver, final AssemblerConfigurationSource configSource) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException, DependencyResolutionException {
Map<DependencySet, Set<Artifact>> resolved = dependencyResolver.resolveDependencySets(assembly, configSource, assembly.getDependencySets());
for (Map.Entry<DependencySet, Set<Artifact>> dependencySetSetEntry : resolved.entrySet()) {
final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(dependencySetSetEntry.getKey()), dependencySetSetEntry.getValue(), configSource.getProject(), projectBuilder, getLogger());
task.execute(archiver, configSource);
}
}
use of org.apache.maven.plugins.assembly.archive.task.AddDependencySetsTask in project maven-plugins by apache.
the class ModuleSetAssemblyPhase method addModuleBinaries.
void addModuleBinaries(final Assembly assembly, ModuleSet moduleSet, final ModuleBinaries binaries, final Set<MavenProject> projects, final Archiver archiver, final AssemblerConfigurationSource configSource) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException, DependencyResolutionException {
if (binaries == null) {
return;
}
final Set<MavenProject> moduleProjects = new LinkedHashSet<MavenProject>();
MavenProjects.select(projects, "pom", log(getLogger()), addTo(moduleProjects));
final String classifier = binaries.getAttachmentClassifier();
final Map<MavenProject, Artifact> chosenModuleArtifacts = new HashMap<MavenProject, Artifact>();
for (final MavenProject project : moduleProjects) {
Artifact artifact;
if (classifier == null) {
getLogger().debug("Processing binary artifact for module project: " + project.getId());
artifact = project.getArtifact();
} else {
getLogger().debug("Processing binary attachment: " + classifier + " for module project: " + project.getId());
artifact = MavenProjects.findArtifactByClassifier(project, classifier);
if (artifact == null) {
throw new InvalidAssemblerConfigurationException("Cannot find attachment with classifier: " + classifier + " in module project: " + project.getId() + ". Please exclude this module from the module-set.");
}
}
chosenModuleArtifacts.put(project, artifact);
addModuleArtifact(artifact, project, archiver, configSource, binaries);
}
final List<DependencySet> depSets = getDependencySets(binaries);
if (depSets != null) {
Map<DependencySet, Set<Artifact>> dependencySetSetMap = dependencyResolver.resolveDependencySets(assembly, moduleSet, configSource, depSets);
for (final DependencySet ds : depSets) {
// NOTE: Disabling useProjectArtifact flag, since module artifact has already been handled!
ds.setUseProjectArtifact(false);
}
// TODO: The following should be moved into a shared component, cause this
// test is the same as in maven-enforce rules ReactorModuleConvergence.
List<MavenProject> validateModuleVersions = validateModuleVersions(moduleProjects);
if (!validateModuleVersions.isEmpty()) {
StringBuilder sb = new StringBuilder().append("The current modules seemed to be having different versions.");
sb.append(LINE_SEPARATOR);
for (MavenProject mavenProject : validateModuleVersions) {
sb.append(" --> ");
sb.append(mavenProject.getId());
sb.append(LINE_SEPARATOR);
}
getLogger().warn(sb.toString());
}
for (final MavenProject moduleProject : moduleProjects) {
getLogger().debug("Processing binary dependencies for module project: " + moduleProject.getId());
for (Map.Entry<DependencySet, Set<Artifact>> dependencySetSetEntry : dependencySetSetMap.entrySet()) {
final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(dependencySetSetEntry.getKey()), dependencySetSetEntry.getValue(), moduleProject, projectBuilder, getLogger());
task.setModuleProject(moduleProject);
task.setModuleArtifact(chosenModuleArtifacts.get(moduleProject));
task.setDefaultOutputDirectory(binaries.getOutputDirectory());
task.setDefaultOutputFileNameMapping(binaries.getOutputFileNameMapping());
task.execute(archiver, configSource);
}
}
}
}
Aggregations