use of org.apache.maven.artifact.resolver.filter.ArtifactFilter in project maven-dependency-plugin by apache.
the class AbstractAnalyzeMojo method filterDependencies.
private List<Artifact> filterDependencies(Set<Artifact> artifacts, String[] excludes) throws MojoExecutionException {
ArtifactFilter filter = new StrictPatternExcludesArtifactFilter(Arrays.asList(excludes));
List<Artifact> result = new ArrayList<Artifact>();
for (Iterator<Artifact> it = artifacts.iterator(); it.hasNext(); ) {
Artifact artifact = it.next();
if (!filter.include(artifact)) {
it.remove();
result.add(artifact);
}
}
return result;
}
use of org.apache.maven.artifact.resolver.filter.ArtifactFilter in project fabric8 by jboss-fuse.
the class AbstractProfileMojo method createResolvingArtifactFilter.
/**
* Gets the artifact filter to use when resolving the dependency tree.
*
* @return the artifact filter
*/
private ArtifactFilter createResolvingArtifactFilter() {
ArtifactFilter filter;
if (scope != null) {
getLog().debug("+ Resolving dependency tree for scope '" + scope + "'");
filter = new ScopeArtifactFilter(scope);
} else {
filter = null;
}
return filter;
}
use of org.apache.maven.artifact.resolver.filter.ArtifactFilter in project scala-maven-plugin by davidB.
the class ScalaMojoSupport method createScalaDistroDependencyFilter.
/**
* @return
* A filter to only extract artifacts deployed from scala distributions
*/
private DependencyNodeFilter createScalaDistroDependencyFilter() {
List<ArtifactFilter> filters = new ArrayList<ArtifactFilter>();
filters.add(new ScalaDistroArtifactFilter(getScalaOrganization()));
return new AndDependencyNodeFilter(filters);
}
use of org.apache.maven.artifact.resolver.filter.ArtifactFilter in project maven-plugins by apache.
the class FilterUtilsTest method testFilterArtifacts_ShouldRemoveArtifactExcludedByAdditionalFilter.
public void testFilterArtifacts_ShouldRemoveArtifactExcludedByAdditionalFilter() throws InvalidAssemblerConfigurationException {
final ArtifactFilter filter = new ArtifactFilter() {
public boolean include(final Artifact artifact) {
return false;
}
};
verifyArtifactExclusion("group", "artifact", "fail:fail", null, null, filter);
}
use of org.apache.maven.artifact.resolver.filter.ArtifactFilter in project maven-plugins by apache.
the class TreeMojo method execute.
// Mojo methods -----------------------------------------------------------
/*
* @see org.apache.maven.plugin.Mojo#execute()
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (isSkip()) {
getLog().info("Skipping plugin execution");
return;
}
try {
String dependencyTreeString;
// TODO: note that filter does not get applied due to MSHARED-4
ArtifactFilter artifactFilter = createResolvingArtifactFilter();
if (verbose) {
// To fix we probably need a different DependencyCollector in Aether, which doesn't remove nodes which
// have already been resolved.
getLog().info("Verbose not supported since maven-dependency-plugin 3.0");
}
ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
buildingRequest.setProject(project);
// non-verbose mode use dependency graph component, which gives consistent results with Maven version
// running
rootNode = dependencyGraphBuilder.buildDependencyGraph(buildingRequest, artifactFilter, reactorProjects);
dependencyTreeString = serializeDependencyTree(rootNode);
if (outputFile != null) {
DependencyUtil.write(dependencyTreeString, outputFile, this.appendOutput, getLog());
getLog().info("Wrote dependency tree to: " + outputFile);
} else {
DependencyUtil.log(dependencyTreeString, getLog());
}
} catch (DependencyGraphBuilderException exception) {
throw new MojoExecutionException("Cannot build project dependency graph", exception);
} catch (IOException exception) {
throw new MojoExecutionException("Cannot serialise project dependency graph", exception);
}
}
Aggregations