{
results = includeSingleScope( artifacts, includeScope );
}
else
{
ScopeArtifactFilter saf = new ScopeArtifactFilter( includeScope );
Iterator iter = artifacts.iterator();
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();
if ( saf.include( artifact ) )
{
results.add( artifact );
}
}
}
}
else if ( StringUtils.isNotEmpty( excludeScope ) )
{
if ( !Artifact.SCOPE_COMPILE.equals( excludeScope ) && !Artifact.SCOPE_TEST.equals( excludeScope )
&& !Artifact.SCOPE_PROVIDED.equals( excludeScope ) && !Artifact.SCOPE_RUNTIME.equals( excludeScope )
&& !Artifact.SCOPE_SYSTEM.equals( excludeScope ) )
{
throw new ArtifactFilterException( "Invalid Scope in excludeScope: " + excludeScope );
}
results = new HashSet();
// plexus ScopeArtifactFilter doesn't handle the provided scope so
// we
// need special handling for it.
if ( Artifact.SCOPE_TEST.equals( excludeScope ) )
{
throw new ArtifactFilterException( " Can't exclude Test scope, this will exclude everything." );
}
else if ( !Artifact.SCOPE_PROVIDED.equals( excludeScope ) && !Artifact.SCOPE_SYSTEM.equals( excludeScope ) )
{
ScopeArtifactFilter saf = new ScopeArtifactFilter( excludeScope );
Iterator iter = artifacts.iterator();
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();
if ( !saf.include( artifact ) )
{
results.add( artifact );
}
}
}