Search in sources :

Example 1 with ScopeArtifactFilter

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

the class DefaultRepositoryAssembler method buildRepositoryFilter.

private ArtifactFilter buildRepositoryFilter(RepositoryInfo repository, MavenProject project) {
    AndArtifactFilter filter = new AndArtifactFilter();
    ArtifactFilter scopeFilter = new ScopeArtifactFilter(repository.getScope());
    filter.add(scopeFilter);
    // ----------------------------------------------------------------------------
    // Includes
    // 
    // We'll take everything if no includes are specified to try and make
    // this
    // process more maintainable. Don't want to have to update the assembly
    // descriptor everytime the POM is updated.
    // ----------------------------------------------------------------------------
    List<String> includes = repository.getIncludes();
    if ((includes == null) || includes.isEmpty()) {
        List<String> patterns = new ArrayList<String>();
        Set<Artifact> projectArtifacts = project.getDependencyArtifacts();
        if (projectArtifacts != null) {
            for (Artifact artifact : projectArtifacts) {
                patterns.add(artifact.getDependencyConflictId());
            }
        }
        PatternIncludesArtifactFilter includeFilter = new PatternIncludesArtifactFilter(patterns, true);
        filter.add(includeFilter);
    } else {
        filter.add(new PatternIncludesArtifactFilter(repository.getIncludes(), true));
    }
    // ----------------------------------------------------------------------------
    // Excludes
    // 
    // We still want to make it easy to exclude a few things even if we
    // slurp
    // up everything.
    // ----------------------------------------------------------------------------
    List<String> excludes = repository.getExcludes();
    if ((excludes != null) && !excludes.isEmpty()) {
        filter.add(new PatternExcludesArtifactFilter(repository.getExcludes(), true));
    }
    return filter;
}
Also used : ScopeArtifactFilter(org.apache.maven.shared.artifact.filter.ScopeArtifactFilter) PatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter) AndArtifactFilter(org.apache.maven.artifact.resolver.filter.AndArtifactFilter) ArtifactFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter) PatternIncludesArtifactFilter(org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter) ScopeArtifactFilter(org.apache.maven.shared.artifact.filter.ScopeArtifactFilter) PatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter) PatternIncludesArtifactFilter(org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter) ArrayList(java.util.ArrayList) AndArtifactFilter(org.apache.maven.artifact.resolver.filter.AndArtifactFilter) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

ArrayList (java.util.ArrayList)1 Artifact (org.apache.maven.artifact.Artifact)1 AndArtifactFilter (org.apache.maven.artifact.resolver.filter.AndArtifactFilter)1 ArtifactFilter (org.apache.maven.artifact.resolver.filter.ArtifactFilter)1 PatternExcludesArtifactFilter (org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter)1 PatternIncludesArtifactFilter (org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter)1 ScopeArtifactFilter (org.apache.maven.shared.artifact.filter.ScopeArtifactFilter)1