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


The following commit(s) were added to refs/heads/master by this push:
     new 44087ab  [MARTIFACT-11] copy also .buildinfo.compare aggregate to root
44087ab is described below

commit 44087ab2e8c4e1899745c3771704a0038d2d6f88
Author: Hervé Boutemy <hbout...@apache.org>
AuthorDate: Tue Feb 2 08:34:28 2021 +0100

    [MARTIFACT-11] copy also .buildinfo.compare aggregate to root
---
 .../plugins/artifact/buildinfo/BuildinfoMojo.java  | 44 ++++++++++++++--------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git 
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java 
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java
index e781bfa..929e8d7 100644
--- 
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java
+++ 
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java
@@ -188,22 +188,7 @@ public class BuildinfoMojo
             getLog().info( "NOT adding buildinfo to the list of attached 
artifacts." );
         }
 
-        if ( !mono )
-        {
-            // copy aggregate buildinfo to root target directory
-            MavenProject root = getExecutionRoot();
-            File rootCopy = new File( root.getBuild().getDirectory(),
-                                      root.getArtifactId() + '-' + 
root.getVersion() + ".buildinfo" );
-            try
-            {
-                FileUtils.copyFile( buildinfoFile, rootCopy );
-                getLog().info( "Aggregate buildinfo copied to " + rootCopy );
-            }
-            catch ( IOException ioe )
-            {
-                throw new MojoExecutionException( "Could not copy " + 
buildinfoFile + "to " + rootCopy );
-            }
-        }
+        copyAggregateToRoot( buildinfoFile );
 
         // eventually check against reference
         if ( referenceRepo != null )
@@ -213,6 +198,31 @@ public class BuildinfoMojo
         }
     }
 
+    private void copyAggregateToRoot( File aggregate )
+        throws MojoExecutionException
+    {
+        if ( reactorProjects.size() == 1 )
+        {
+            // mono-module, no aggregate buildinfo to deal with
+            return;
+        }
+
+        // copy aggregate buildinfo to root target directory
+        MavenProject root = getExecutionRoot();
+        String compare = aggregate.getName().endsWith( ".compare" ) ? 
".compare" : "";
+        File rootCopy = new File( root.getBuild().getDirectory(),
+                                  root.getArtifactId() + '-' + 
root.getVersion() + ".buildinfo" + compare );
+        try
+        {
+            FileUtils.copyFile( aggregate, rootCopy );
+            getLog().info( "Aggregate buildinfo" + compare + " copied to " + 
rootCopy );
+        }
+        catch ( IOException ioe )
+        {
+            throw new MojoExecutionException( "Could not copy " + aggregate + 
"to " + rootCopy );
+        }
+    }
+
     /**
      * Generate buildinfo file.
      *
@@ -359,6 +369,8 @@ public class BuildinfoMojo
             {
                 throw new MojoExecutionException( "Error creating file " + 
compare, e );
             }
+
+            copyAggregateToRoot( compare );
         }
     }
 

Reply via email to