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/11/14 18:44:38 UTC
[maven-artifact-plugin] branch master updated: [MARTIFACT-17] add early feedback on multi-module
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 87e7c3b [MARTIFACT-17] add early feedback on multi-module
87e7c3b is described below
commit 87e7c3b5ca15d110c9915e283913f33bbe298f1d
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sun Nov 14 19:44:35 2021 +0100
[MARTIFACT-17] add early feedback on multi-module
---
.../artifact/buildinfo/AbstractBuildinfoMojo.java | 44 ++++++++++++----------
.../plugins/artifact/buildinfo/CompareMojo.java | 25 ++++++++++--
2 files changed, 47 insertions(+), 22 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 f9be2f1..ae0afc3 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
@@ -130,23 +130,6 @@ public abstract class AbstractBuildinfoMojo
{
boolean mono = reactorProjects.size() == 1;
- if ( !mono )
- {
- // if module skips install and/or deploy
- if ( isSkip( project ) )
- {
- getLog().info( "Skipping goal because module skips install and/or deploy" );
- return;
- }
- // if multi-module build, generate (aggregate) buildinfo only in last module
- MavenProject last = getLastProject();
- if ( project != last )
- {
- getLog().info( "Skipping intermediate goal run, aggregate will be " + last.getArtifactId() );
- return;
- }
- }
-
MavenArchiver archiver = new MavenArchiver();
Date timestamp = archiver.parseOutputTimestamp( outputTimestamp );
if ( timestamp == null )
@@ -177,6 +160,23 @@ public abstract class AbstractBuildinfoMojo
}
}
+ if ( !mono )
+ {
+ // if module skips install and/or deploy
+ if ( isSkip( project ) )
+ {
+ getLog().info( "Skipping goal because module skips install and/or deploy" );
+ return;
+ }
+ // if multi-module build, generate (aggregate) buildinfo only in last module
+ MavenProject last = getLastProject();
+ if ( project != last )
+ {
+ skip( last );
+ return;
+ }
+ }
+
// generate buildinfo
Map<Artifact, String> artifacts = generateBuildinfo( mono );
getLog().info( "Saved " + ( mono ? "" : "aggregate " ) + "info on build to " + buildinfoFile );
@@ -195,6 +195,12 @@ public abstract class AbstractBuildinfoMojo
abstract void execute( Map<Artifact, String> artifacts )
throws MojoExecutionException;
+ protected void skip( MavenProject last )
+ throws MojoExecutionException
+ {
+ getLog().info( "Skipping intermediate goal run, aggregate will be " + last.getArtifactId() );
+ }
+
protected void copyAggregateToRoot( File aggregate )
throws MojoExecutionException
{
@@ -228,8 +234,8 @@ public abstract class AbstractBuildinfoMojo
* (<code>outputs.[#module.].#artifact</code>)
* @throws MojoExecutionException
*/
- private Map<Artifact, String> generateBuildinfo( boolean mono )
- throws MojoExecutionException
+ protected Map<Artifact, String> generateBuildinfo( boolean mono )
+ throws MojoExecutionException
{
MavenProject root = mono ? project : getExecutionRoot();
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 fe9ed7b..a6b2e6d 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
@@ -71,6 +71,13 @@ public class CompareMojo
@Parameter( property = "reference.repo", defaultValue = "central" )
private String referenceRepo;
+ /**
+ * Compare aggregate only (ie wait for the last module) or do buildcompare on each module.
+ * @since 3.2.0
+ */
+ @Parameter( property = "compare.aggregate.only", defaultValue = "false" )
+ private boolean aggregateOnly;
+
@Component
private ArtifactFactory artifactFactory;
@@ -100,7 +107,20 @@ public class CompareMojo
throws MojoExecutionException
{
getLog().info( "Checking against reference build from " + referenceRepo + "..." );
- checkAgainstReference( artifacts );
+ checkAgainstReference( artifacts, reactorProjects.size() == 1 );
+ }
+
+ @Override
+ protected void skip( MavenProject last )
+ throws MojoExecutionException
+ {
+ if ( aggregateOnly )
+ {
+ return;
+ }
+
+ // try to download reference artifacts for current project and check if there are issues to give early feedback
+ checkAgainstReference( generateBuildinfo( true ), true );
}
/**
@@ -110,10 +130,9 @@ public class CompareMojo
* (<code>outputs.[#module.].#artifact</code>)
* @throws MojoExecutionException
*/
- private void checkAgainstReference( Map<Artifact, String> artifacts )
+ private void checkAgainstReference( Map<Artifact, String> artifacts, boolean mono )
throws MojoExecutionException
{
- boolean mono = reactorProjects.size() == 1;
MavenProject root = mono ? project : getExecutionRoot();
File referenceDir = new File( root.getBuild().getDirectory(), "reference" );
referenceDir.mkdirs();