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;
}
Aggregations