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

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

commit e455452e76c0ad9ba3d7fe4a6013a821564ba2e7
Author: Hervé Boutemy <hbout...@apache.org>
AuthorDate: Mon Sep 22 08:49:08 2025 +0200

    improve summary: promote diffoscope in .buildcompare
---
 .../artifact/buildinfo/AbstractBuildinfoMojo.java  | 14 ++++++--
 .../plugins/artifact/buildinfo/CompareMojo.java    | 42 +++++++++++-----------
 2 files changed, 32 insertions(+), 24 deletions(-)

diff --git 
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java
 
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java
index 2fbeb6f..cba2931 100644
--- 
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java
+++ 
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java
@@ -305,10 +305,10 @@ public abstract class AbstractBuildinfoMojo extends 
AbstractMojo {
         getLog().info("Skipping intermediate goal run, aggregate will be " + 
last.getArtifactId());
     }
 
-    protected void copyAggregateToRoot(File aggregate) throws 
MojoExecutionException {
+    protected File copyAggregateToRoot(File aggregate) throws 
MojoExecutionException {
         if (session.getProjects().size() == 1) {
             // mono-module, no aggregate file to deal with
-            return;
+            return aggregate;
         }
 
         // copy aggregate file to root target directory
@@ -323,10 +323,11 @@ public abstract class AbstractBuildinfoMojo extends 
AbstractMojo {
                     rootCopy.toPath(),
                     LinkOption.NOFOLLOW_LINKS,
                     StandardCopyOption.REPLACE_EXISTING);
-            getLog().info("Aggregate " + extension.substring(1) + " copied to 
" + rootCopy);
+            getLog().info("Aggregate " + extension.substring(1) + " copied to 
" + relative(rootCopy));
         } catch (IOException ioe) {
             throw new MojoExecutionException("Could not copy " + aggregate + " 
to " + rootCopy, ioe);
         }
+        return rootCopy;
     }
 
     protected BuildInfoWriter newBuildInfoWriter(PrintWriter p, boolean mono) {
@@ -413,4 +414,11 @@ public abstract class AbstractBuildinfoMojo extends 
AbstractMojo {
 
         return tc;
     }
+
+    protected String relative(File file) {
+        File basedir = session.getTopLevelProject().getBasedir();
+        int length = basedir.getPath().length();
+        String path = file.getPath();
+        return path.substring(length + 1);
+    }
 }
diff --git 
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojo.java 
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojo.java
index bda4391..0b56bac 100644
--- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojo.java
+++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojo.java
@@ -195,19 +195,14 @@ public class CompareMojo extends AbstractBuildinfoMojo {
         int missing = reference.size() / 3 /* 3 property keys par file: 
filename, length and checksums.sha512 */;
 
         if (ko + missing > 0) {
-            getLog().error("Reproducible Build output summary: "
-                    + MessageUtils.buffer().success(ok + " files ok")
-                    + ", " + MessageUtils.buffer().failure(ko + " different")
+            getLog().error("[Reproducible Builds] rebuild comparison result: "
+                    + MessageUtils.buffer().success(ok + " files match")
+                    + ", " + MessageUtils.buffer().failure(ko + " differ")
                     + ((missing == 0) ? "" : (", " + 
MessageUtils.buffer().failure(missing + " missing")))
                     + ((ignored.isEmpty()) ? "" : (", " + 
MessageUtils.buffer().warning(ignored.size() + " ignored"))));
-            getLog().error("see "
-                    + MessageUtils.buffer()
-                            .project("diff " + relative(referenceBuildinfo) + 
" " + relative(buildinfoFile))
-                            .build());
-            getLog().error("see also 
https://maven.apache.org/guides/mini/guide-reproducible-builds.html";);
         } else {
-            getLog().info("Reproducible Build output summary: "
-                    + MessageUtils.buffer().success(ok + " files ok")
+            getLog().info("[Reproducible Builds] rebuild comparison result: "
+                    + MessageUtils.buffer().success(ok + " files match")
                     + ((ignored.isEmpty()) ? "" : (", " + 
MessageUtils.buffer().warning(ignored.size() + " ignored"))));
         }
 
@@ -243,15 +238,27 @@ public class CompareMojo extends AbstractBuildinfoMojo {
                 p.print("# ");
                 p.println(diffoscope);
             }
-            getLog().info("Reproducible Build output comparison saved to " + 
buildcompare);
         } catch (IOException e) {
             throw new MojoExecutionException("Error creating file " + 
buildcompare, e);
         }
 
-        copyAggregateToRoot(buildcompare);
+        String saved = "                                                 saved 
to " + relative(buildcompare);
+        if (ko + missing > 0) {
+            getLog().error(saved);
+        } else {
+            getLog().info(saved);
+        }
+        buildcompare = copyAggregateToRoot(buildcompare);
+
+        if (ko + missing > 0) {
+            getLog().error("[Reproducible Builds] to analyze the differences, 
see diffoscope instructions in "
+                    + relative(buildcompare));
+            getLog().error(
+                            "                      see also 
https://maven.apache.org/guides/mini/guide-reproducible-builds.html";);
 
-        if (fail && (ko + missing > 0)) {
-            throw new MojoExecutionException("Build artifacts are different 
from reference");
+            if (fail) {
+                throw new MojoExecutionException("Rebuilt artifacts are 
different from reference");
+            }
         }
     }
 
@@ -300,13 +307,6 @@ public class CompareMojo extends AbstractBuildinfoMojo {
         return path.substring(path.lastIndexOf('/'));
     }
 
-    private String relative(File file) {
-        File basedir = session.getTopLevelProject().getBasedir();
-        int length = basedir.getPath().length();
-        String path = file.getPath();
-        return path.substring(length + 1);
-    }
-
     private static String findPrefix(Properties reference, String 
actualGroupId, String actualFilename) {
         for (String name : reference.stringPropertyNames()) {
             if (name.endsWith(".filename") && 
actualFilename.equals(reference.getProperty(name))) {

Reply via email to