Search in sources :

Example 1 with SpecificScopesArtifactFilter

use of org.apache.maven.ant.tasks.support.SpecificScopesArtifactFilter in project maven-plugins by apache.

the class DependencyFilesetsTask method filterArtifacts.

/**
     * Filter a set of artifacts using the scopes and type filters.
     *
     * @param artifacts {@link Artifact} set.
     * @return The set of filtered artifacts.
     */
public Set<Artifact> filterArtifacts(Set<Artifact> artifacts) {
    if (scopes == null) {
        scopes = "";
    }
    if (types == null) {
        types = "";
    }
    if (scopes.equals("") && types.equals("")) {
        return artifacts;
    }
    AndArtifactFilter filter = new AndArtifactFilter();
    if (!scopes.equals("")) {
        filter.add(new SpecificScopesArtifactFilter(getScopes()));
    }
    if (!types.equals("")) {
        filter.add(new TypesArtifactFilter(getTypes()));
    }
    Set<Artifact> artifactsResult = new LinkedHashSet<Artifact>();
    for (Artifact artifact : artifacts) {
        if (filter.include(artifact)) {
            artifactsResult.add(artifact);
        }
    }
    return artifactsResult;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TypesArtifactFilter(org.apache.maven.ant.tasks.support.TypesArtifactFilter) SpecificScopesArtifactFilter(org.apache.maven.ant.tasks.support.SpecificScopesArtifactFilter) AndArtifactFilter(org.apache.maven.artifact.resolver.filter.AndArtifactFilter) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 SpecificScopesArtifactFilter (org.apache.maven.ant.tasks.support.SpecificScopesArtifactFilter)1 TypesArtifactFilter (org.apache.maven.ant.tasks.support.TypesArtifactFilter)1 Artifact (org.apache.maven.artifact.Artifact)1 AndArtifactFilter (org.apache.maven.artifact.resolver.filter.AndArtifactFilter)1