You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/02/02 09:57:01 UTC

[maven-artifact-plugin] branch MARTIFACT-35 created (now 91ad338)

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

michaelo pushed a change to branch MARTIFACT-35
in repository https://gitbox.apache.org/repos/asf/maven-artifact-plugin.git


      at 91ad338  [MARTIFACT-35] Compare goal should fail build when comparison was unsuccessful

This branch includes the following new commits:

     new 91ad338  [MARTIFACT-35] Compare goal should fail build when comparison was unsuccessful

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-artifact-plugin] 01/01: [MARTIFACT-35] Compare goal should fail build when comparison was unsuccessful

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

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

commit 91ad3385f22f1b548d592e4ba75393db15eb825e
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Thu Feb 2 10:42:51 2023 +0100

    [MARTIFACT-35] Compare goal should fail build when comparison was unsuccessful
---
 src/it/compare-mono/invoker.properties                  |  1 +
 .../maven/plugins/artifact/buildinfo/CompareMojo.java   | 17 +++++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/it/compare-mono/invoker.properties b/src/it/compare-mono/invoker.properties
index 339a145..fe14eb3 100644
--- a/src/it/compare-mono/invoker.properties
+++ b/src/it/compare-mono/invoker.properties
@@ -17,3 +17,4 @@
 
 invoker.goals.1=clean install
 invoker.goals.2=clean package artifact:compare
+invoker.buildResult.2=failure
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 a6b2e6d..78bef86 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
@@ -192,12 +192,12 @@ public class CompareMojo
 
         if ( ko + missing > 0 )
         {
-            getLog().warn( "Reproducible Build output summary: " + MessageUtils.buffer().success( ok + " files ok" )
+            getLog().error( "Reproducible Build output summary: " + MessageUtils.buffer().success( ok + " files ok" )
                 + ", " + MessageUtils.buffer().failure( ko + " different" )
-                + ( ( missing == 0 ) ? "" : ( ", " + MessageUtils.buffer().warning( missing + " missing" ) ) ) );
-            getLog().warn( "see " + MessageUtils.buffer().project( "diff " + relative( referenceBuildinfo ) + " "
+                + ( ( missing == 0 ) ? "" : ( ", " + MessageUtils.buffer().failure( missing + " missing" ) ) ) );
+            getLog().error( "see " + MessageUtils.buffer().project( "diff " + relative( referenceBuildinfo ) + " "
                 + relative( buildinfoFile ) ).toString() );
-            getLog().warn( "see also https://maven.apache.org/guides/mini/guide-reproducible-builds.html" );
+            getLog().error( "see also https://maven.apache.org/guides/mini/guide-reproducible-builds.html" );
           }
         else
         {
@@ -241,6 +241,11 @@ public class CompareMojo
         }
 
         copyAggregateToRoot( buildcompare );
+
+        if ( ko + missing > 0 )
+        {
+            throw new MojoExecutionException( "Build artifacts are not reproducible" );
+        }
     }
 
     // { filename, diffoscope }
@@ -268,8 +273,8 @@ public class CompareMojo
         if ( issue != null )
         {
             String diffoscope = diffoscope( artifact, referenceDir );
-            getLog().warn( issue + " mismatch " + MessageUtils.buffer().strong( actualFilename ) + ": investigate with "
-                + MessageUtils.buffer().project( diffoscope ) );
+            getLog().error( issue + " mismatch " + MessageUtils.buffer().strong( actualFilename )
+                + ": investigate with " + MessageUtils.buffer().project( diffoscope ) );
             return new String[] { actualFilename,  diffoscope };
         }
         return new String[] { actualFilename, null };