You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2019/12/15 23:47:25 UTC

[maven-project-info-reports-plugin] branch MPIR-375 created (now 8e66c06)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch MPIR-375
in repository https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git.


      at 8e66c06  [MPIR-375] Modified with suggestions provided in PR #7 by Robert Scholte:

This branch includes the following new commits:

     new 8e66c06  [MPIR-375] Modified with suggestions provided in PR #7 by Robert Scholte:

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-project-info-reports-plugin] 01/01: [MPIR-375] Modified with suggestions provided in PR #7 by Robert Scholte:

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MPIR-375
in repository https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git

commit 8e66c06a46a9b73dcccfcb3385849a18d7b52d4c
Author: Gabriel Belingueres <be...@gmail.com>
AuthorDate: Mon Jan 14 14:34:58 2019 -0300

    [MPIR-375] Modified with suggestions provided in PR #7 by Robert Scholte:
    
    - Removed unnecessary code in tests.
    - Narrowed scope of try-catch when building the report.
    - Simplified exclusion logic by using PatternExcludesArtifactFilter.
---
 src/it/MPIR-375/pom.xml                            |  5 --
 .../report/projectinfo/PluginManagementReport.java | 62 +++++-----------------
 .../plugin-management-plugin-config-MPIR-375.xml   |  7 ---
 3 files changed, 14 insertions(+), 60 deletions(-)

diff --git a/src/it/MPIR-375/pom.xml b/src/it/MPIR-375/pom.xml
index 16afb89..acb0755 100644
--- a/src/it/MPIR-375/pom.xml
+++ b/src/it/MPIR-375/pom.xml
@@ -73,11 +73,6 @@
     </pluginManagement>
 
     <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-site-plugin</artifactId>
-        <version>@sitePluginVersion@</version>
-      </plugin>
       <!--
       Example plugin generating the Eclipse's "Plugin execution not covered by lifecycle configuration" error message
        -->
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 a9f088b..cddd113 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
@@ -34,6 +34,7 @@ import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter;
 import org.codehaus.plexus.i18n.I18N;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -128,7 +129,7 @@ public class PluginManagementReport
 
         private final ProjectBuildingRequest buildingRequest;
         
-        private final List<String> excludes;
+        private final PatternExcludesArtifactFilter patternExcludesArtifactFilter;
 
         /**
          * @param log {@link #log}
@@ -161,7 +162,7 @@ public class PluginManagementReport
 
             this.buildingRequest = buildingRequest;
 
-            this.excludes = excludes;
+            this.patternExcludesArtifactFilter = new PatternExcludesArtifactFilter( excludes );
         }
 
         @Override
@@ -220,14 +221,10 @@ public class PluginManagementReport
 
                 Artifact pluginArtifact = repositorySystem.createProjectArtifact( plugin.getGroupId(), plugin
                     .getArtifactId(), versionRange.toString() );
-                
-                try
+
+                if ( patternExcludesArtifactFilter.include( pluginArtifact ) )
                 {
-                    if ( isExcluded( pluginArtifact ) )
-                    {
-                        log.debug( "Excluding plugin " + pluginArtifact.getId() + " from report" );
-                    }
-                    else
+                    try
                     {
                         MavenProject pluginProject =
                             projectBuilder.build( pluginArtifact, buildingRequest ).getProject();
@@ -235,13 +232,17 @@ public class PluginManagementReport
                         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 );
+                        tableRow( getPluginRow( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(),
+                                                null ) );
+                    }
                 }
-                catch ( ProjectBuildingException e )
+                else
                 {
-                    log.info( "Could not build project for: " + plugin.getArtifactId() + ":" + e.getMessage(), e );
-                    tableRow( getPluginRow( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), null ) );
+                    log.debug( "Excluding plugin " + pluginArtifact.getId() + " from report" );
                 }
-
             }
             endTable();
 
@@ -283,41 +284,6 @@ public class PluginManagementReport
                 }
             };
         }
-        
-        private boolean isExcluded( Artifact pluginArtifact )
-        {
-            if ( excludes == null )
-            {
-                return false;
-            }
 
-            for ( String pattern : excludes )
-            {
-                String[] subStrings = pattern.split( ":" );
-                subStrings = StringUtils.stripAll( subStrings );
-                String resultPattern = StringUtils.join( subStrings, ":" );
-
-                if ( compareDependency( resultPattern, pluginArtifact ) )
-                {
-                    return true;
-                }
-            }
-
-            return false;
-        }
-
-        /**
-         * Compares the given pattern against the given artifact. The pattern should follow the format
-         * <code>groupId:artifactId:type:classifier:version</code>.
-         * 
-         * @param pattern The pattern to compare the artifact with.
-         * @param artifact the artifact
-         * @return <code>true</code> if the artifact matches the pattern
-         */
-        protected boolean compareDependency( String pattern, Artifact artifact )
-        {
-            // TODO: compare with a better pattern matcher, like class ArtifactMatcher from Enforcer rules plugin
-            return artifact.getId().startsWith( pattern );
-        }
     }
 }
diff --git a/src/test/resources/plugin-configs/plugin-management-plugin-config-MPIR-375.xml b/src/test/resources/plugin-configs/plugin-management-plugin-config-MPIR-375.xml
index 6a94350..fc99bcd 100644
--- a/src/test/resources/plugin-configs/plugin-management-plugin-config-MPIR-375.xml
+++ b/src/test/resources/plugin-configs/plugin-management-plugin-config-MPIR-375.xml
@@ -24,13 +24,6 @@ under the License.
   <version>1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
   <name>plugin management project info</name>
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-    </dependency>
-  </dependencies>
 
   <build>
     <pluginManagement>