Search in sources :

Example 1 with ArtifactsFilter

use of org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter in project syndesis by syndesisio.

the class RepackageExtensionMojo method getAdditionalFilters.

@Override
protected Collection<ArtifactsFilter> getAdditionalFilters() {
    Collection<MavenDependency> dependencies = new HashSet<>();
    if (StringUtils.isNotBlank(blackListedBoms)) {
        addCustomBoms(dependencies);
    } else {
        addDefaultBOMs(dependencies);
    }
    if (StringUtils.isNotBlank(blackListedGAVs)) {
        addCustomGAVs(dependencies);
    } else {
        addDefaultGAVs(dependencies);
    }
    if (getLog().isDebugEnabled()) {
        getLog().debug("Filtering out dependencies from the following BOMs: " + bomsUsed);
        getLog().debug("Dependencies to be filtered out:");
        dependencies.stream().sorted(Comparator.comparing(MavenCoordinate::toCanonicalForm)).forEach(mavenDependency -> getLog().debug(mavenDependency.toCanonicalForm()));
    }
    List<ArtifactsFilter> filters = new ArrayList<>(dependencies.size());
    for (MavenCoordinate dep : dependencies) {
        filters.add(newExcludeFilter(dep));
    }
    return filters;
}
Also used : MavenCoordinate(org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinate) ArrayList(java.util.ArrayList) ArtifactsFilter(org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter) MavenDependency(org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency) HashSet(java.util.HashSet)

Example 2 with ArtifactsFilter

use of org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter in project spring-boot by spring-projects.

the class RepackageMojo method getAdditionalFilters.

private ArtifactsFilter[] getAdditionalFilters() {
    List<ArtifactsFilter> filters = new ArrayList<>();
    if (this.excludeDevtools) {
        Exclude exclude = new Exclude();
        exclude.setGroupId("org.springframework.boot");
        exclude.setArtifactId("spring-boot-devtools");
        ExcludeFilter filter = new ExcludeFilter(exclude);
        filters.add(filter);
    }
    if (!this.includeSystemScope) {
        filters.add(new ScopeFilter(null, Artifact.SCOPE_SYSTEM));
    }
    return filters.toArray(new ArtifactsFilter[filters.size()]);
}
Also used : ScopeFilter(org.apache.maven.shared.artifact.filter.collection.ScopeFilter) ArrayList(java.util.ArrayList) ArtifactsFilter(org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter)

Example 3 with ArtifactsFilter

use of org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter in project spring-boot by spring-projects.

the class AbstractPackagerMojo method getAdditionalFilters.

private ArtifactsFilter[] getAdditionalFilters() {
    List<ArtifactsFilter> filters = new ArrayList<>();
    if (this.excludeDevtools) {
        Exclude exclude = new Exclude();
        exclude.setGroupId("org.springframework.boot");
        exclude.setArtifactId("spring-boot-devtools");
        ExcludeFilter filter = new ExcludeFilter(exclude);
        filters.add(filter);
    }
    if (!this.includeSystemScope) {
        filters.add(new ScopeFilter(null, Artifact.SCOPE_SYSTEM));
    }
    return filters.toArray(new ArtifactsFilter[0]);
}
Also used : ScopeFilter(org.apache.maven.shared.artifact.filter.collection.ScopeFilter) ArrayList(java.util.ArrayList) ArtifactsFilter(org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter)

Example 4 with ArtifactsFilter

use of org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter in project spring-boot by spring-projects.

the class AbstractDependencyFilterMojo method getFilters.

/**
 * Return artifact filters configured for this MOJO.
 * @param additionalFilters optional additional filters to apply
 * @return the filters
 */
protected final FilterArtifacts getFilters(ArtifactsFilter... additionalFilters) {
    FilterArtifacts filters = new FilterArtifacts();
    for (ArtifactsFilter additionalFilter : additionalFilters) {
        filters.addFilter(additionalFilter);
    }
    filters.addFilter(new MatchingGroupIdFilter(cleanFilterConfig(this.excludeGroupIds)));
    if (this.includes != null && !this.includes.isEmpty()) {
        filters.addFilter(new IncludeFilter(this.includes));
    }
    if (this.excludes != null && !this.excludes.isEmpty()) {
        filters.addFilter(new ExcludeFilter(this.excludes));
    }
    filters.addFilter(new JarTypeFilter());
    return filters;
}
Also used : FilterArtifacts(org.apache.maven.shared.artifact.filter.collection.FilterArtifacts) ArtifactsFilter(org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter)

Example 5 with ArtifactsFilter

use of org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter in project syndesis by syndesisio.

the class SupportMojo method filterDependencies.

@Override
protected Set<Artifact> filterDependencies(Set<Artifact> dependencies, FilterArtifacts filters) throws MojoExecutionException {
    try {
        Set<Artifact> filtered = new LinkedHashSet<Artifact>(dependencies);
        @SuppressWarnings("unchecked") Collection<ArtifactsFilter> filtersToUse = filters.getFilters();
        filtersToUse.addAll(getAdditionalFilters());
        filtered.retainAll(filters.filter(dependencies));
        return filtered;
    } catch (ArtifactFilterException ex) {
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArtifactFilterException(org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArtifactsFilter(org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

ArtifactsFilter (org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter)5 ArrayList (java.util.ArrayList)3 ScopeFilter (org.apache.maven.shared.artifact.filter.collection.ScopeFilter)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Artifact (org.apache.maven.artifact.Artifact)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ArtifactFilterException (org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException)1 FilterArtifacts (org.apache.maven.shared.artifact.filter.collection.FilterArtifacts)1 MavenCoordinate (org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinate)1 MavenDependency (org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency)1