Search in sources :

Example 81 with ProjectBuildingRequest

use of org.apache.maven.project.ProjectBuildingRequest in project maven-plugins by apache.

the class ResolvePluginsMojo method resolvePluginArtifacts.

/**
 * This method resolves the plugin artifacts from the project.
 *
 * @return set of resolved plugin artifacts.
 * @throws ArtifactFilterException in case of an error.
 * @throws ArtifactResolverException in case of an error.
 */
protected Set<Artifact> resolvePluginArtifacts() throws ArtifactFilterException, ArtifactResolverException {
    final Set<Artifact> plugins = getProject().getPluginArtifacts();
    final Set<Artifact> reports = getProject().getReportArtifacts();
    Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
    artifacts.addAll(reports);
    artifacts.addAll(plugins);
    final FilterArtifacts filter = getPluginArtifactsFilter();
    artifacts = filter.filter(artifacts);
    Set<Artifact> resolvedArtifacts = new LinkedHashSet<Artifact>(artifacts.size());
    // final ArtifactFilter filter = getPluginFilter();
    for (final Artifact artifact : new LinkedHashSet<Artifact>(artifacts)) {
        // if ( !filter.include( artifact ) )
        // {
        // final String logStr =
        // String.format( " Plugin SKIPPED: %s", DependencyUtil.getFormattedFileName( artifact, false ) );
        // 
        // if ( !silent )
        // {
        // this.getLog().info( logStr );
        // }
        // 
        // artifacts.remove( artifact );
        // continue;
        // }
        ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
        buildingRequest.setRemoteRepositories(this.remotePluginRepositories);
        // resolve the new artifact
        resolvedArtifacts.add(getArtifactResolver().resolveArtifact(buildingRequest, artifact).getArtifact());
    }
    return artifacts;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) DefaultProjectBuildingRequest(org.apache.maven.project.DefaultProjectBuildingRequest) FilterArtifacts(org.apache.maven.shared.artifact.filter.collection.FilterArtifacts) Artifact(org.apache.maven.artifact.Artifact) DefaultProjectBuildingRequest(org.apache.maven.project.DefaultProjectBuildingRequest)

Aggregations

ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)81 File (java.io.File)40 DefaultProjectBuildingRequest (org.apache.maven.project.DefaultProjectBuildingRequest)37 MavenRepositorySystemSession (org.apache.maven.repository.internal.MavenRepositorySystemSession)28 SimpleLocalRepositoryManager (org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager)28 Artifact (org.apache.maven.artifact.Artifact)25 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)22 MavenProject (org.apache.maven.project.MavenProject)22 MavenSession (org.apache.maven.execution.MavenSession)17 IOException (java.io.IOException)14 LegacySupport (org.apache.maven.plugin.LegacySupport)13 ArtifactResolverException (org.apache.maven.shared.artifact.resolve.ArtifactResolverException)12 ArrayList (java.util.ArrayList)9 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)8 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)8 ArchetypeGenerationRequest (org.apache.maven.archetype.ArchetypeGenerationRequest)7 ArchetypeManager (org.apache.maven.archetype.ArchetypeManager)7 ArchetypeCatalog (org.apache.maven.archetype.catalog.ArchetypeCatalog)7 ProjectBuildingException (org.apache.maven.project.ProjectBuildingException)7 ArtifactResult (org.apache.maven.shared.artifact.resolve.ArtifactResult)7