use of org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter in project maven-dependency-plugin by apache.
the class AbstractResolveMojo method getPluginArtifactsFilter.
/**
* @return {@link FilterArtifacts}
*/
protected FilterArtifacts getPluginArtifactsFilter() {
if (excludeReactor) {
final StringBuilder exAids = new StringBuilder();
if (this.excludeArtifactIds != null) {
exAids.append(this.excludeArtifactIds);
}
for (final MavenProject rp : reactorProjects) {
if (!"maven-plugin".equals(rp.getPackaging())) {
continue;
}
if (exAids.length() > 0) {
exAids.append(",");
}
exAids.append(rp.getArtifactId());
}
this.excludeArtifactIds = exAids.toString();
}
final FilterArtifacts filter = new FilterArtifacts();
// CHECKSTYLE_OFF: LineLength
filter.addFilter(new org.apache.maven.shared.artifact.filter.collection.ScopeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeScope), DependencyUtil.cleanToBeTokenizedString(this.excludeScope)));
// CHECKSTYLE_ON: LineLength
filter.addFilter(new TypeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeTypes), DependencyUtil.cleanToBeTokenizedString(this.excludeTypes)));
filter.addFilter(new ClassifierFilter(DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers)));
filter.addFilter(new GroupIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds)));
filter.addFilter(new ArtifactIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds)));
return filter;
}
use of org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter in project maven-dependency-plugin by apache.
the class AbstractDependencyFilterMojo method getDependencySets.
/**
* Method creates filters and filters the projects dependencies. This method also transforms the dependencies if
* classifier is set. The dependencies are filtered in least specific to most specific order
*
* @param stopOnFailure true to fail if artifacts can't be resolved false otherwise.
* @param includeParents <code>true</code> if parents should be included or not <code>false</code>.
* @return DependencyStatusSets - Bean of TreeSets that contains information on the projects dependencies
* @throws MojoExecutionException in case of errors.
*/
protected DependencyStatusSets getDependencySets(boolean stopOnFailure, boolean includeParents) throws MojoExecutionException {
// add filters in well known order, least specific to most specific
FilterArtifacts filter = new FilterArtifacts();
filter.addFilter(new ProjectTransitivityFilter(getProject().getDependencyArtifacts(), this.excludeTransitive));
filter.addFilter(new ScopeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeScope), DependencyUtil.cleanToBeTokenizedString(this.excludeScope)));
filter.addFilter(new TypeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeTypes), DependencyUtil.cleanToBeTokenizedString(this.excludeTypes)));
filter.addFilter(new ClassifierFilter(DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers)));
filter.addFilter(new GroupIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds)));
filter.addFilter(new ArtifactIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds)));
// start with all artifacts.
Set<Artifact> artifacts = getProject().getArtifacts();
if (includeParents) {
// add dependencies parents
for (Artifact dep : new ArrayList<Artifact>(artifacts)) {
addParentArtifacts(buildProjectFromArtifact(dep), artifacts);
}
// add current project parent
addParentArtifacts(getProject(), artifacts);
}
// perform filtering
try {
artifacts = filter.filter(artifacts);
} catch (ArtifactFilterException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
// transform artifacts if classifier is set
DependencyStatusSets status;
if (StringUtils.isNotEmpty(classifier)) {
status = getClassifierTranslatedDependencies(artifacts, stopOnFailure);
} else {
status = filterMarkedDependencies(artifacts);
}
return status;
}
use of org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter in project maven-plugins by apache.
the class AbstractResolveMojo method getPluginArtifactsFilter.
protected FilterArtifacts getPluginArtifactsFilter() {
if (excludeReactor) {
final StringBuilder exAids = new StringBuilder();
if (this.excludeArtifactIds != null) {
exAids.append(this.excludeArtifactIds);
}
for (final MavenProject rp : reactorProjects) {
if (!"maven-plugin".equals(rp.getPackaging())) {
continue;
}
if (exAids.length() > 0) {
exAids.append(",");
}
exAids.append(rp.getArtifactId());
}
this.excludeArtifactIds = exAids.toString();
}
final FilterArtifacts filter = new FilterArtifacts();
// CHECKSTYLE_OFF: LineLength
filter.addFilter(new org.apache.maven.shared.artifact.filter.collection.ScopeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeScope), DependencyUtil.cleanToBeTokenizedString(this.excludeScope)));
// CHECKSTYLE_ON: LineLength
filter.addFilter(new TypeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeTypes), DependencyUtil.cleanToBeTokenizedString(this.excludeTypes)));
filter.addFilter(new ClassifierFilter(DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers)));
filter.addFilter(new GroupIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds)));
filter.addFilter(new ArtifactIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds)));
return filter;
}
use of org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter in project m2e-nar by maven-nar.
the class AbstractDependencyMojo method prepareNarArtifacts.
@SuppressWarnings("unchecked")
public void prepareNarArtifacts(final ConfiguratorContext context, IMavenProjectFacade facade, IProgressMonitor monitor) throws MojoExecutionException, CoreException, MojoFailureException {
narDependencies = new LinkedList<NarArtifact>();
FilterArtifacts filter = new FilterArtifacts();
filter.addFilter(new GroupIdFilter(cleanToBeTokenizedString(this.includeGroupIds), cleanToBeTokenizedString(this.excludeGroupIds)));
filter.addFilter(new ArtifactIdFilter(cleanToBeTokenizedString(this.includeArtifactIds), cleanToBeTokenizedString(this.excludeArtifactIds)));
filter.addFilter(getArtifactScopeFilter());
Set<Artifact> artifacts = getMavenProject().getArtifacts();
// perform filtering
try {
artifacts = filter.filter(artifacts);
} catch (ArtifactFilterException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
for (final Artifact dependency : artifacts) {
getLog().debug("Examining artifact for NarInfo: " + dependency);
NarLayout layout;
EclipseNarLayout eclipseLayout = resolveEclipseProject(dependency, context, facade, monitor);
NarInfo narInfo;
if (eclipseLayout != null) {
layout = eclipseLayout;
narInfo = getNarInfo(dependency, eclipseLayout);
} else {
layout = getLayout();
narInfo = getNarInfo(dependency);
}
if (narInfo != null) {
getLog().debug(" - added as NarDependency");
narDependencies.add(new NarArtifact(dependency, narInfo, layout));
}
}
getLog().debug("Dependencies contained " + narDependencies.size() + " NAR artifacts.");
}
use of org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter in project maven-plugins by apache.
the class AbstractDependencyFilterMojo method getDependencySets.
/**
* Method creates filters and filters the projects dependencies. This method also transforms the dependencies if
* classifier is set. The dependencies are filtered in least specific to most specific order
*
* @param stopOnFailure true to fail if artifacts can't be resolved false otherwise.
* @param includeParents <code>true</code> if parents should be included or not <code>false</code>.
* @return DependencyStatusSets - Bean of TreeSets that contains information on the projects dependencies
* @throws MojoExecutionException in case of errors.
*/
protected DependencyStatusSets getDependencySets(boolean stopOnFailure, boolean includeParents) throws MojoExecutionException {
// add filters in well known order, least specific to most specific
FilterArtifacts filter = new FilterArtifacts();
filter.addFilter(new ProjectTransitivityFilter(getProject().getDependencyArtifacts(), this.excludeTransitive));
filter.addFilter(new ScopeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeScope), DependencyUtil.cleanToBeTokenizedString(this.excludeScope)));
filter.addFilter(new TypeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeTypes), DependencyUtil.cleanToBeTokenizedString(this.excludeTypes)));
filter.addFilter(new ClassifierFilter(DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers)));
filter.addFilter(new GroupIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds)));
filter.addFilter(new ArtifactIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds)));
// start with all artifacts.
Set<Artifact> artifacts = getProject().getArtifacts();
if (includeParents) {
// add dependencies parents
for (Artifact dep : new ArrayList<Artifact>(artifacts)) {
addParentArtifacts(buildProjectFromArtifact(dep), artifacts);
}
// add current project parent
addParentArtifacts(getProject(), artifacts);
}
// perform filtering
try {
artifacts = filter.filter(artifacts);
} catch (ArtifactFilterException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
// transform artifacts if classifier is set
DependencyStatusSets status;
if (StringUtils.isNotEmpty(classifier)) {
status = getClassifierTranslatedDependencies(artifacts, stopOnFailure);
} else {
status = filterMarkedDependencies(artifacts);
}
return status;
}
Aggregations