You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2021/01/15 07:15:01 UTC
[maven-artifact-plugin] branch master updated: [MARTIFACT-8] copy
aggregate buildinfo to root target/ directory
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 7ea7f79 [MARTIFACT-8] copy aggregate buildinfo to root target/ directory
7ea7f79 is described below
commit 7ea7f796a2310fbd4153e7ccdb65e4d9388f1b4a
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Fri Jan 15 08:14:57 2021 +0100
[MARTIFACT-8] copy aggregate buildinfo to root target/ directory
---
src/it/multi/verify.groovy | 7 +++++--
src/it/skip-install-deploy/verify.groovy | 4 ++--
.../plugins/artifact/buildinfo/BuildinfoMojo.java | 19 +++++++++++++++++++
3 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/src/it/multi/verify.groovy b/src/it/multi/verify.groovy
index 5c3c583..a41bd0c 100644
--- a/src/it/multi/verify.groovy
+++ b/src/it/multi/verify.groovy
@@ -18,9 +18,9 @@
* under the License.
*/
-// check existence of generated aggregate buildinfo in target
+// check existence of generated aggregate buildinfo in target and its copy in root
File buildinfoFile = new File( basedir, "target/multi-1.0-SNAPSHOT.buildinfo" );
-assert !buildinfoFile.isFile()
+assert buildinfoFile.isFile()
File modA = new File( basedir, "modA/target/multi-modA-1.0-SNAPSHOT.buildinfo")
assert !modA.isFile()
@@ -28,6 +28,9 @@ assert !modA.isFile()
File modB = new File( basedir, "modB/target/multi-modB-1.0-SNAPSHOT.buildinfo")
assert modB.isFile()
+// check that copy content in root is the same
+assert buildinfoFile.text.equals( modB.text )
+
// check generated aggregate buildinfo content
String buildinfo = modB.text
assert buildinfo.contains( "group-id=org.apache.maven.plugins.it" )
diff --git a/src/it/skip-install-deploy/verify.groovy b/src/it/skip-install-deploy/verify.groovy
index 4dbd7ca..bd814e1 100644
--- a/src/it/skip-install-deploy/verify.groovy
+++ b/src/it/skip-install-deploy/verify.groovy
@@ -18,9 +18,9 @@
* under the License.
*/
-// check existence of generated aggregate buildinfo in target
+// check existence of generated aggregate buildinfo in target and root copy
File buildinfoFile = new File( basedir, "target/multi-1.0-SNAPSHOT.buildinfo" );
-assert !buildinfoFile.isFile()
+assert buildinfoFile.isFile()
File modA = new File( basedir, "modA/target/multi-modA-1.0-SNAPSHOT.buildinfo")
assert !modA.isFile()
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 f29ecff..98914e5 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
@@ -32,6 +32,7 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.utils.logging.MessageUtils;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.RepositorySystem;
@@ -177,6 +178,7 @@ public class BuildinfoMojo
// eventually attach
if ( attach )
{
+ getLog().info( "Attaching buildinfo" );
projectHelper.attachArtifact( project, "buildinfo", buildinfoFile );
}
else
@@ -184,6 +186,23 @@ 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 );
+ }
+ }
+
// eventually check against reference
if ( referenceRepo != null )
{