Skip to content

Commit

Permalink
[MARTIFACT-74] describe groupId(s) and duplicate artifactId(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Oct 27, 2024
1 parent d735ec1 commit 094434e
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
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;
Expand Down Expand Up @@ -58,8 +61,25 @@ private void describeBuildOutput() throws MojoExecutionException {
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());
Expand Down Expand Up @@ -92,11 +112,11 @@ private void describeBuildOutput() throws MojoExecutionException {
}
}
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)
Expand All @@ -107,7 +127,7 @@ private void describeBuildOutput() throws MojoExecutionException {
}
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));
}
}
}
Expand Down

0 comments on commit 094434e

Please sign in to comment.