private void describeBuildOutput()

in src/main/java/org/apache/maven/plugins/artifact/buildinfo/DescribeBuildOutputMojo.java [83:169]


    private void describeBuildOutput() throws MojoExecutionException {
        rootPath = session.getTopLevelProject().getBasedir().toPath();
        bi = newBuildInfoWriter(null, false);

        Map<MavenProject, Long> reactorParents = session.getProjects().stream()
                .collect(Collectors.groupingBy(
                        p -> DescribeBuildOutputMojo.getReactorParent(session, p), Collectors.counting()));
        reactorParents.entrySet().stream()
                .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
                .forEach(e -> getLog().info("parent in reactor: " + e.getKey().getGroupId() + ":"
                        + e.getKey().getArtifactId() + " @ "
                        + rootPath.relativize(e.getKey().getFile().toPath()) + " (" + e.getValue() + " module"
                        + ((e.getValue() > 1) ? "s" : "") + "), property = "
                        + e.getKey().getProperties().get("project.build.outputTimestamp")));

        getLog().info("");

        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")
                .strong("[:classifier][:extension]")
                .a(" = build-path repository-filename size [sha256]")
                .build());

        for (MavenProject p : session.getProjects()) {
            boolean skipped = isSkip(p);
            String s = skipped ? "not-deployed " : "             ";

            // project = pom
            // detect Maven 4 consumer POM transient attachment
            Artifact consumerPom = RepositoryUtils.toArtifacts(p.getAttachedArtifacts()).stream()
                    .filter(a -> "pom".equals(a.getExtension()) && "consumer".equals(a.getClassifier()))
                    .findAny()
                    .orElse(null);

            Artifact pomArtifact = new DefaultArtifact(p.getGroupId(), p.getArtifactId(), null, "pom", p.getVersion());
            if (consumerPom != null) {
                // Maven 4 transient consumer POM attachment is published as the POM, overrides build POM, see
                // https://github.com/apache/maven/blob/c79a7a02721f0f9fd7e202e99f60b593461ba8cc/maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java#L130-L155
                try {
                    Path pomFile = Files.createTempFile(Paths.get(p.getBuild().getDirectory()), "consumer-", ".pom");
                    Files.copy(consumerPom.getFile().toPath(), pomFile, StandardCopyOption.REPLACE_EXISTING);
                    pomArtifact = pomArtifact.setFile(pomFile.toFile());
                    getLog().info(s + describeArtifact(pomArtifact)); // consumer pom
                    // build pom
                    pomArtifact =
                            new DefaultArtifact(p.getGroupId(), p.getArtifactId(), "build", "pom", p.getVersion());
                } catch (IOException e) {
                    throw new MojoExecutionException("Error processing consumer POM", e);
                }
            }
            pomArtifact = pomArtifact.setFile(p.getFile());
            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()), skipped));
            }

            // attached artifacts (when available)
            for (Artifact a : RepositoryUtils.toArtifacts(p.getAttachedArtifacts())) {
                if ("pom".equals(a.getExtension()) && "consumer".equals(a.getClassifier())) {
                    // ignore transient consumer POM attachment
                    continue;
                }
                boolean ignored = skipped ? false : isIgnore(a);
                String i = skipped ? s : (ignored ? "RB-ignored   " : "             ");
                getLog().info(i + describeArtifact(a, skipped || ignored));
            }
        }
    }