use of org.apache.maven.shared.artifact.filter.resolve.ScopeFilter in project maven-plugins by apache.
the class AddDependencySetsTask method resolveDependencyArtifacts.
Set<Artifact> resolveDependencyArtifacts(final DependencySet dependencySet) throws InvalidAssemblerConfigurationException {
final Set<Artifact> dependencyArtifacts = new LinkedHashSet<Artifact>();
if (resolvedArtifacts != null) {
dependencyArtifacts.addAll(resolvedArtifacts);
}
if (dependencySet.isUseProjectArtifact()) {
final Artifact projectArtifact = project.getArtifact();
if ((projectArtifact != null) && (projectArtifact.getFile() != null)) {
dependencyArtifacts.add(projectArtifact);
} else {
logger.warn("Cannot include project artifact: " + projectArtifact + "; it doesn't have an associated file or directory.");
}
}
if (dependencySet.isUseProjectAttachments()) {
final List<Artifact> attachments = project.getAttachedArtifacts();
if (attachments != null) {
for (final Artifact attachment : attachments) {
if (attachment.getFile() != null) {
dependencyArtifacts.add(attachment);
} else {
logger.warn("Cannot include attached artifact: " + project.getId() + " for project: " + project.getId() + "; it doesn't have an associated file or directory.");
}
}
}
}
if (dependencySet.isUseTransitiveFiltering()) {
logger.debug("Filtering dependency artifacts USING transitive dependency path information.");
} else {
logger.debug("Filtering dependency artifacts WITHOUT transitive dependency path information.");
}
final ScopeFilter scopeFilter = FilterUtils.newScopeFilter(dependencySet.getScope());
final ArtifactFilter filter = new ArtifactIncludeFilterTransformer().transform(scopeFilter);
FilterUtils.filterArtifacts(dependencyArtifacts, dependencySet.getIncludes(), dependencySet.getExcludes(), dependencySet.isUseStrictFiltering(), dependencySet.isUseTransitiveFiltering(), logger, filter);
return dependencyArtifacts;
}
use of org.apache.maven.shared.artifact.filter.resolve.ScopeFilter in project maven-plugins by apache.
the class DefaultDependencyResolver method updateDependencySetResolutionRequirements.
void updateDependencySetResolutionRequirements(final DependencySet set, final ResolutionManagementInfo requirements, AssemblyId assemblyId, ProjectBuildingRequest buildingRequest, final MavenProject... projects) throws DependencyResolutionException {
requirements.setResolutionRequired(true);
requirements.setResolvedTransitively(set.isUseTransitiveDependencies());
ScopeFilter scopeFilter = FilterUtils.newScopeFilter(set.getScope());
requirements.setScopeFilter(scopeFilter);
for (final MavenProject project : projects) {
if (project == null) {
continue;
}
Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
if (dependencyArtifacts == null) {
try {
ProjectBuildingRequest pbr = new DefaultProjectBuildingRequest(buildingRequest);
pbr.setRemoteRepositories(project.getRemoteArtifactRepositories());
Iterable<ArtifactResult> artifactResults = dependencyResolver.resolveDependencies(pbr, project.getModel(), scopeFilter);
dependencyArtifacts = new HashSet<Artifact>();
for (ArtifactResult artifactResult : artifactResults) {
dependencyArtifacts.add(artifactResult.getArtifact());
}
project.setDependencyArtifacts(dependencyArtifacts);
} catch (final DependencyResolverException e) {
throw new DependencyResolutionException("Failed to create dependency artifacts for resolution. Assembly: " + assemblyId, e);
}
}
requirements.addArtifacts(dependencyArtifacts);
getLogger().debug("Dependencies for project: " + project.getId() + " are:\n" + StringUtils.join(dependencyArtifacts.iterator(), "\n"));
}
}
Aggregations