From d28e98b8cfedbe179a1017d1a221871919841415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Sun, 20 Feb 2022 22:51:30 +0100 Subject: [PATCH] [MPIR-413] Plugin repositories defined in project are not used by plugin management report This closes #32 --- .../projectinfo/PluginManagementReport.java | 14 +++++++------- .../report/projectinfo/PluginsReport.java | 18 +++++------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java b/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java index cddd113d..05ae58d4 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java @@ -53,17 +53,17 @@ public class PluginManagementReport extends AbstractProjectInfoReport { - + /** * Specify the excluded plugins. This can be a list of artifacts in the format * groupId[:artifactId[:type[:version]]].
* Plugins matching any exclude will not be present in the report. - * + * * @since 3.0.1 */ @Parameter private List pluginManagementExcludes = null; - + // ---------------------------------------------------------------------- // Public methods // ---------------------------------------------------------------------- @@ -128,7 +128,7 @@ protected static class PluginManagementRenderer private final RepositorySystem repositorySystem; private final ProjectBuildingRequest buildingRequest; - + private final PatternExcludesArtifactFilter patternExcludesArtifactFilter; /** @@ -206,7 +206,7 @@ private void renderSectionPluginManagement() ProjectBuildingRequest buildRequest = new DefaultProjectBuildingRequest( buildingRequest ); buildRequest.setRemoteRepositories( project.getPluginArtifactRepositories() ); - + for ( Plugin plugin : pluginManagement ) { VersionRange versionRange; @@ -227,14 +227,14 @@ private void renderSectionPluginManagement() try { MavenProject pluginProject = - projectBuilder.build( pluginArtifact, buildingRequest ).getProject(); + projectBuilder.build( pluginArtifact, buildRequest ).getProject(); tableRow( getPluginRow( pluginProject.getGroupId(), pluginProject.getArtifactId(), pluginProject.getVersion(), pluginProject.getUrl() ) ); } catch ( ProjectBuildingException e ) { - log.info( "Could not build project for: " + plugin.getArtifactId() + ":" + e.getMessage(), e ); + log.info( "Could not build project for " + plugin.getArtifactId(), e ); tableRow( getPluginRow( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), null ) ); } diff --git a/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java b/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java index b831c916..9570c778 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java @@ -26,7 +26,6 @@ import java.util.Locale; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Plugin; @@ -173,7 +172,7 @@ public void renderBody() private void renderSectionPlugins( boolean isPlugins ) { List list = isPlugins ? GAV.pluginsToGAV( plugins ) : GAV.reportPluginsToGAV( reports, project ); - + String[] tableHeader = getPluginTableHeader(); startSection( getI18nString( isPlugins ? "build.title" : "report.title" ) ); @@ -191,20 +190,14 @@ private void renderSectionPlugins( boolean isPlugins ) startTable(); tableHeader( tableHeader ); - List artifactRepositories = project.getPluginArtifactRepositories(); - if ( artifactRepositories == null ) - { - artifactRepositories = new ArrayList<>(); - } - ProjectBuildingRequest buildRequest = new DefaultProjectBuildingRequest( buildingRequest ); - buildRequest.setRemoteRepositories( artifactRepositories ); - + buildRequest.setRemoteRepositories( project.getPluginArtifactRepositories() ); + for ( GAV plugin : list ) { VersionRange versionRange = VersionRange.createFromVersion( plugin.getVersion() ); - + Artifact pluginArtifact = repositorySystem.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange.toString() ); @@ -217,11 +210,10 @@ private void renderSectionPlugins( boolean isPlugins ) } catch ( ProjectBuildingException e ) { - log.info( "Could not build project for " + plugin.getArtifactId() + ": " + e.getMessage(), e ); + log.info( "Could not build project for " + plugin.getArtifactId(), e ); tableRow( getPluginRow( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), null ) ); } - } endTable();