Search in sources :

Example 1 with PatternInclusionsFilter

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

the class PurgeLocalRepositoryMojo method createPurgeArtifactsFilter.

/**
     * Create the includes exclude filter to use when resolving and purging dependencies Also excludes any "system"
     * scope dependencies
     *
     * @param dependencyArtifacts The dependency artifacts to use as a reference if we're excluding transitive
     *            dependencies
     * @return the created filter
     */
private TransformableFilter createPurgeArtifactsFilter(Set<Artifact> dependencyArtifacts) {
    List<TransformableFilter> subFilters = new ArrayList<TransformableFilter>();
    // System dependencies should never be purged
    subFilters.add(ScopeFilter.excluding(Artifact.SCOPE_SYSTEM));
    if (this.snapshotsOnly) {
        subFilters.add(new SnapshotsFilter());
    }
    // The CLI includes/excludes overrides configuration in the pom
    if (!StringUtils.isEmpty(this.include)) {
        this.includes = parseIncludes(this.include);
    }
    if (this.includes != null) {
        subFilters.add(new PatternInclusionsFilter(includes));
    }
    if (!StringUtils.isEmpty(this.exclude)) {
        this.excludes = parseIncludes(this.exclude);
    }
    if (this.excludes != null) {
        subFilters.add(new PatternExclusionsFilter(excludes));
    }
    if (!actTransitively) {
        subFilters.add(new DirectDependencyFilter(project.getArtifact(), dependencyArtifacts));
    }
    return new AndFilter(subFilters);
}
Also used : AndFilter(org.apache.maven.shared.artifact.filter.resolve.AndFilter) TransformableFilter(org.apache.maven.shared.artifact.filter.resolve.TransformableFilter) PatternInclusionsFilter(org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter) ArrayList(java.util.ArrayList) PatternExclusionsFilter(org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter)

Example 2 with PatternInclusionsFilter

use of org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter in project maven-dependency-plugin by apache.

the class PurgeLocalRepositoryMojo method createPurgeArtifactsFilter.

/**
 * Create the includes exclude filter to use when resolving and purging dependencies Also excludes any "system"
 * scope dependencies
 *
 * @param theProject The Maven project.
 * @param dependencies The dependencies to use as a reference if we're excluding transitive dependencies
 * @param purgedArtifacts The artifacts already purged.
 * @return the created filter
 */
private TransformableFilter createPurgeArtifactsFilter(MavenProject theProject, List<Dependency> dependencies, Set<Artifact> purgedArtifacts) {
    List<TransformableFilter> subFilters = new ArrayList<TransformableFilter>();
    // System dependencies should never be purged
    subFilters.add(ScopeFilter.excluding(Artifact.SCOPE_SYSTEM));
    if (this.snapshotsOnly) {
        subFilters.add(new SnapshotsFilter());
    }
    // The CLI includes/excludes overrides configuration in the pom
    if (!StringUtils.isEmpty(this.include)) {
        this.includes = parseIncludes(this.include);
    }
    if (this.includes != null) {
        subFilters.add(new PatternInclusionsFilter(includes));
    }
    if (!StringUtils.isEmpty(this.exclude)) {
        this.excludes = parseIncludes(this.exclude);
    }
    if (this.excludes != null) {
        subFilters.add(new PatternExclusionsFilter(excludes));
    }
    if (!actTransitively) {
        subFilters.add(new DirectDependencyFilter(theProject.getArtifact(), dependencies));
    }
    List<String> exclusions = new ArrayList<String>(reactorProjects.size());
    // It doesn't make sense to include projects from the reactor here since they're likely not able to be resolved
    for (MavenProject reactorProject : reactorProjects) {
        exclusions.add(toPatternExcludes(reactorProject.getArtifact()));
    }
    // There is no need to consider a second time artifacts that were already purged (re-resolved or not)
    for (Artifact purgedArtifact : purgedArtifacts) {
        exclusions.add(toPatternExcludes(purgedArtifact));
    }
    subFilters.add(new PatternExclusionsFilter(exclusions));
    return new AndFilter(subFilters);
}
Also used : AndFilter(org.apache.maven.shared.artifact.filter.resolve.AndFilter) TransformableFilter(org.apache.maven.shared.artifact.filter.resolve.TransformableFilter) PatternInclusionsFilter(org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) PatternExclusionsFilter(org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter) Artifact(org.apache.maven.artifact.Artifact)

Example 3 with PatternInclusionsFilter

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

the class AbstractJavadocMojo method getDependencySourcePaths.

/**
     * Resolve dependency sources so they can be included directly in the javadoc process. To customize this,
     * override {@link AbstractJavadocMojo#configureDependencySourceResolution(SourceResolverConfig)}.
     * @return List of source paths.
     * @throws MavenReportException {@link MavenReportException}
     */
protected final List<String> getDependencySourcePaths() throws MavenReportException {
    try {
        if (sourceDependencyCacheDir.exists()) {
            FileUtils.forceDelete(sourceDependencyCacheDir);
            sourceDependencyCacheDir.mkdirs();
        }
    } catch (IOException e) {
        throw new MavenReportException("Failed to delete cache directory: " + sourceDependencyCacheDir + "\nReason: " + e.getMessage(), e);
    }
    final SourceResolverConfig config = getDependencySourceResolverConfig();
    final List<TransformableFilter> andFilters = new ArrayList<TransformableFilter>();
    final List<String> dependencyIncludes = dependencySourceIncludes;
    final List<String> dependencyExcludes = dependencySourceExcludes;
    if (!includeTransitiveDependencySources || isNotEmpty(dependencyIncludes) || isNotEmpty(dependencyExcludes)) {
        if (!includeTransitiveDependencySources) {
            andFilters.add(createDependencyArtifactFilter());
        }
        if (isNotEmpty(dependencyIncludes)) {
            andFilters.add(new PatternInclusionsFilter(dependencyIncludes));
        }
        if (isNotEmpty(dependencyExcludes)) {
            andFilters.add(new PatternExclusionsFilter(dependencyExcludes));
        }
        config.withFilter(new AndFilter(andFilters));
    }
    try {
        return resourceResolver.resolveDependencySourcePaths(config);
    } catch (final ArtifactResolutionException e) {
        throw new MavenReportException("Failed to resolve one or more javadoc source/resource artifacts:\n\n" + e.getMessage(), e);
    } catch (final ArtifactNotFoundException e) {
        throw new MavenReportException("Failed to resolve one or more javadoc source/resource artifacts:\n\n" + e.getMessage(), e);
    }
}
Also used : PatternInclusionsFilter(org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) PatternExclusionsFilter(org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter) AndFilter(org.apache.maven.shared.artifact.filter.resolve.AndFilter) ArtifactResolutionException(org.apache.maven.artifact.resolver.ArtifactResolutionException) TransformableFilter(org.apache.maven.shared.artifact.filter.resolve.TransformableFilter) SourceResolverConfig(org.apache.maven.plugin.javadoc.resolver.SourceResolverConfig) ArtifactNotFoundException(org.apache.maven.artifact.resolver.ArtifactNotFoundException) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 4 with PatternInclusionsFilter

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

the class AbstractJavadocMojo method createDependencyArtifactFilter.

/**
     * Returns a ArtifactFilter that only includes direct dependencies of this project
     * (verified via groupId and artifactId).
     *
     * @return
     */
private TransformableFilter createDependencyArtifactFilter() {
    Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
    List<String> artifactPatterns = new ArrayList<String>(dependencyArtifacts.size());
    for (Artifact artifact : dependencyArtifacts) {
        artifactPatterns.add(artifact.getGroupId() + ":" + artifact.getArtifactId());
    }
    return new PatternInclusionsFilter(artifactPatterns);
}
Also used : PatternInclusionsFilter(org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter) ArrayList(java.util.ArrayList) JavadocPathArtifact(org.apache.maven.plugin.javadoc.options.JavadocPathArtifact) Artifact(org.apache.maven.artifact.Artifact) DocletArtifact(org.apache.maven.plugin.javadoc.options.DocletArtifact) BootclasspathArtifact(org.apache.maven.plugin.javadoc.options.BootclasspathArtifact) ResourcesArtifact(org.apache.maven.plugin.javadoc.options.ResourcesArtifact) TagletArtifact(org.apache.maven.plugin.javadoc.options.TagletArtifact)

Example 5 with PatternInclusionsFilter

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

the class PurgeLocalRepositoryMojo method createPurgeArtifactsFilter.

/**
 * Create the includes exclude filter to use when resolving and purging dependencies Also excludes any "system"
 * scope dependencies
 *
 * @param project The Maven project.
 * @param dependencies The dependencies to use as a reference if we're excluding transitive dependencies
 * @param purgedArtifacts The artifacts already purged.
 * @return the created filter
 */
private TransformableFilter createPurgeArtifactsFilter(MavenProject project, List<Dependency> dependencies, Set<Artifact> purgedArtifacts) {
    List<TransformableFilter> subFilters = new ArrayList<TransformableFilter>();
    // System dependencies should never be purged
    subFilters.add(ScopeFilter.excluding(Artifact.SCOPE_SYSTEM));
    if (this.snapshotsOnly) {
        subFilters.add(new SnapshotsFilter());
    }
    // The CLI includes/excludes overrides configuration in the pom
    if (!StringUtils.isEmpty(this.include)) {
        this.includes = parseIncludes(this.include);
    }
    if (this.includes != null) {
        subFilters.add(new PatternInclusionsFilter(includes));
    }
    if (!StringUtils.isEmpty(this.exclude)) {
        this.excludes = parseIncludes(this.exclude);
    }
    if (this.excludes != null) {
        subFilters.add(new PatternExclusionsFilter(excludes));
    }
    if (!actTransitively) {
        subFilters.add(new DirectDependencyFilter(project.getArtifact(), dependencies));
    }
    List<String> exclusions = new ArrayList<String>(reactorProjects.size());
    // It doesn't make sense to include projects from the reactor here since they're likely not able to be resolved
    for (MavenProject reactorProject : reactorProjects) {
        exclusions.add(toPatternExcludes(reactorProject.getArtifact()));
    }
    // There is no need to consider a second time artifacts that were already purged (re-resolved or not)
    for (Artifact purgedArtifact : purgedArtifacts) {
        exclusions.add(toPatternExcludes(purgedArtifact));
    }
    subFilters.add(new PatternExclusionsFilter(exclusions));
    return new AndFilter(subFilters);
}
Also used : AndFilter(org.apache.maven.shared.artifact.filter.resolve.AndFilter) TransformableFilter(org.apache.maven.shared.artifact.filter.resolve.TransformableFilter) PatternInclusionsFilter(org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) PatternExclusionsFilter(org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

ArrayList (java.util.ArrayList)7 PatternInclusionsFilter (org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter)7 AndFilter (org.apache.maven.shared.artifact.filter.resolve.AndFilter)5 PatternExclusionsFilter (org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter)5 TransformableFilter (org.apache.maven.shared.artifact.filter.resolve.TransformableFilter)5 Artifact (org.apache.maven.artifact.Artifact)4 IOException (java.io.IOException)2 ArtifactNotFoundException (org.apache.maven.artifact.resolver.ArtifactNotFoundException)2 ArtifactResolutionException (org.apache.maven.artifact.resolver.ArtifactResolutionException)2 MavenProject (org.apache.maven.project.MavenProject)2 MavenReportException (org.apache.maven.reporting.MavenReportException)2 BootclasspathArtifact (org.apache.maven.plugin.javadoc.options.BootclasspathArtifact)1 DocletArtifact (org.apache.maven.plugin.javadoc.options.DocletArtifact)1 JavadocPathArtifact (org.apache.maven.plugin.javadoc.options.JavadocPathArtifact)1 ResourcesArtifact (org.apache.maven.plugin.javadoc.options.ResourcesArtifact)1 TagletArtifact (org.apache.maven.plugin.javadoc.options.TagletArtifact)1 SourceResolverConfig (org.apache.maven.plugin.javadoc.resolver.SourceResolverConfig)1 BootclasspathArtifact (org.apache.maven.plugins.javadoc.options.BootclasspathArtifact)1 DocletArtifact (org.apache.maven.plugins.javadoc.options.DocletArtifact)1 JavadocPathArtifact (org.apache.maven.plugins.javadoc.options.JavadocPathArtifact)1