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

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-artifact-plugin.git

commit 094434e03c2cd7564a5110e5f4f9749921abd28d
Author: Hervé Boutemy <hbout...@apache.org>
AuthorDate: Wed Oct 16 01:45:39 2024 +0200

    [MARTIFACT-74] describe groupId(s) and duplicate artifactId(s)
---
 .../buildinfo/DescribeBuildOutputMojo.java         | 28 ++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git 
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/DescribeBuildOutputMojo.java
 
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/DescribeBuildOutputMojo.java
index 21e6529..3fadd63 100644
--- 
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/DescribeBuildOutputMojo.java
+++ 
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/DescribeBuildOutputMojo.java
@@ -25,7 +25,10 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
+import java.util.Comparator;
 import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.maven.RepositoryUtils;
@@ -58,8 +61,25 @@ public class DescribeBuildOutputMojo extends 
AbstractBuildinfoMojo {
         rootPath = getExecutionRoot().getBasedir().toPath();
         bi = newBuildInfoWriter(null, false);
 
+        Map<String, Long> groupIds = session.getProjects().stream()
+                .collect(Collectors.groupingBy(MavenProject::getGroupId, 
Collectors.counting()));
+        groupIds.entrySet().stream()
+                .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
+                .forEach(e -> getLog().info("groupId: " + e.getKey() + " (" + 
e.getValue() + " artifactId"
+                        + ((e.getValue() > 1) ? "s" : "") + ")"));
+
+        Map<String, Set<String>> artifactIds = session.getProjects().stream()
+                .collect(Collectors.groupingBy(
+                        MavenProject::getArtifactId, 
Collectors.mapping(MavenProject::getGroupId, Collectors.toSet())));
+        artifactIds.entrySet().stream()
+                .sorted(Map.Entry.comparingByKey())
+                .filter(e -> e.getValue().size() > 1)
+                .forEach(e ->
+                        getLog().info("artifactId: " + e.getKey() + " defined 
for multiple groupIds: " + e.getValue()));
+
+        getLog().info("");
         getLog().info(MessageUtils.buffer()
-                .a("skip/ignore artifactId")
+                .a("skip/ignore? artifactId")
                 .strong("[:classifier][:extension]")
                 .a(" = build-path repository-filename size [sha256]")
                 .build());
@@ -92,11 +112,11 @@ public class DescribeBuildOutputMojo extends 
AbstractBuildinfoMojo {
                 }
             }
             pomArtifact = pomArtifact.setFile(p.getFile());
-            getLog().info(s + describeArtifact(pomArtifact));
+            getLog().info(s + describeArtifact(pomArtifact, skipped));
 
             // main artifact (when available: pom packaging does not provide 
main artifact)
             if (p.getArtifact().getFile() != null) {
-                getLog().info(s + 
describeArtifact(RepositoryUtils.toArtifact(p.getArtifact())));
+                getLog().info(s + 
describeArtifact(RepositoryUtils.toArtifact(p.getArtifact()), skipped));
             }
 
             // attached artifacts (when available)
@@ -107,7 +127,7 @@ public class DescribeBuildOutputMojo extends 
AbstractBuildinfoMojo {
                 }
                 boolean ignored = skipped ? false : isIgnore(a);
                 String i = skipped ? s : (ignored ? "RB-ignored   " : "        
     ");
-                getLog().info(i + describeArtifact(a, ignored));
+                getLog().info(i + describeArtifact(a, skipped || ignored));
             }
         }
     }

Reply via email to