Search in sources :

Example 1 with StrictPatternExcludesArtifactFilter

use of org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter in project maven-dependency-plugin by apache.

the class TreeMojo method createDependencyNodeFilter.

/**
 * Gets the dependency node filter to use when serializing the dependency graph.
 *
 * @return the dependency node filter, or <code>null</code> if none required
 */
private DependencyNodeFilter createDependencyNodeFilter() {
    List<DependencyNodeFilter> filters = new ArrayList<DependencyNodeFilter>();
    // filter includes
    if (includes != null) {
        List<String> patterns = Arrays.asList(includes.split(","));
        getLog().debug("+ Filtering dependency tree by artifact include patterns: " + patterns);
        ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter(patterns);
        filters.add(new ArtifactDependencyNodeFilter(artifactFilter));
    }
    // filter excludes
    if (excludes != null) {
        List<String> patterns = Arrays.asList(excludes.split(","));
        getLog().debug("+ Filtering dependency tree by artifact exclude patterns: " + patterns);
        ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter(patterns);
        filters.add(new ArtifactDependencyNodeFilter(artifactFilter));
    }
    return filters.isEmpty() ? null : new AndDependencyNodeFilter(filters);
}
Also used : StrictPatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter) ArtifactFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter) StrictPatternIncludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter) ScopeArtifactFilter(org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter) StrictPatternIncludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter) ArtifactDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.ArtifactDependencyNodeFilter) StrictPatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter) AndDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.AndDependencyNodeFilter) ArtifactDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.ArtifactDependencyNodeFilter) DependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.DependencyNodeFilter) AndDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.AndDependencyNodeFilter) AncestorOrSelfDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.AncestorOrSelfDependencyNodeFilter) ArrayList(java.util.ArrayList)

Example 2 with StrictPatternExcludesArtifactFilter

use of org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter in project maven-plugins 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;
}
Also used : StrictPatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter) ArtifactFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter) StrictPatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter) ArrayList(java.util.ArrayList) Artifact(org.apache.maven.artifact.Artifact)

Example 3 with StrictPatternExcludesArtifactFilter

use of org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter 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;
}
Also used : StrictPatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter) ArtifactFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter) StrictPatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter) ArrayList(java.util.ArrayList) Artifact(org.apache.maven.artifact.Artifact)

Example 4 with StrictPatternExcludesArtifactFilter

use of org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter in project maven-plugins by apache.

the class TreeMojo method createDependencyNodeFilter.

/**
 * Gets the dependency node filter to use when serializing the dependency graph.
 *
 * @return the dependency node filter, or <code>null</code> if none required
 */
private DependencyNodeFilter createDependencyNodeFilter() {
    List<DependencyNodeFilter> filters = new ArrayList<DependencyNodeFilter>();
    // filter includes
    if (includes != null) {
        List<String> patterns = Arrays.asList(includes.split(","));
        getLog().debug("+ Filtering dependency tree by artifact include patterns: " + patterns);
        ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter(patterns);
        filters.add(new ArtifactDependencyNodeFilter(artifactFilter));
    }
    // filter excludes
    if (excludes != null) {
        List<String> patterns = Arrays.asList(excludes.split(","));
        getLog().debug("+ Filtering dependency tree by artifact exclude patterns: " + patterns);
        ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter(patterns);
        filters.add(new ArtifactDependencyNodeFilter(artifactFilter));
    }
    return filters.isEmpty() ? null : new AndDependencyNodeFilter(filters);
}
Also used : StrictPatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter) ArtifactFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter) StrictPatternIncludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter) ScopeArtifactFilter(org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter) StrictPatternIncludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter) ArtifactDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.ArtifactDependencyNodeFilter) StrictPatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter) AndDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.AndDependencyNodeFilter) ArtifactDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.ArtifactDependencyNodeFilter) DependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.DependencyNodeFilter) AndDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.AndDependencyNodeFilter) AncestorOrSelfDependencyNodeFilter(org.apache.maven.shared.dependency.graph.filter.AncestorOrSelfDependencyNodeFilter) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)4 ArtifactFilter (org.apache.maven.artifact.resolver.filter.ArtifactFilter)4 StrictPatternExcludesArtifactFilter (org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter)4 Artifact (org.apache.maven.artifact.Artifact)2 ScopeArtifactFilter (org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter)2 StrictPatternIncludesArtifactFilter (org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter)2 AncestorOrSelfDependencyNodeFilter (org.apache.maven.shared.dependency.graph.filter.AncestorOrSelfDependencyNodeFilter)2 AndDependencyNodeFilter (org.apache.maven.shared.dependency.graph.filter.AndDependencyNodeFilter)2 ArtifactDependencyNodeFilter (org.apache.maven.shared.dependency.graph.filter.ArtifactDependencyNodeFilter)2 DependencyNodeFilter (org.apache.maven.shared.dependency.graph.filter.DependencyNodeFilter)2