You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2021/01/03 12:10:08 UTC

[maven] branch master updated: [MNG-7060] Let build fail fast in case any maven-gpg-plugin goal is called

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

rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 94612f9  [MNG-7060] Let build fail fast in case any maven-gpg-plugin goal is called
94612f9 is described below

commit 94612f96fa3b96ccc69072dc7b141fd0a987262f
Author: rfscholte <rf...@apache.org>
AuthorDate: Sun Jan 3 13:09:59 2021 +0100

    [MNG-7060] Let build fail fast in case any maven-gpg-plugin goal is called
---
 .../lifecycle/internal/builder/BuilderCommon.java  | 22 +++++++++++++++++++++-
 .../java/org/apache/maven/feature/Features.java    | 10 +++++++++-
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java
index c0cd289..2b5d6ec 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java
@@ -20,6 +20,7 @@ package org.apache.maven.lifecycle.internal.builder;
  */
 
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -32,6 +33,7 @@ import org.apache.maven.execution.BuildFailure;
 import org.apache.maven.execution.ExecutionEvent;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.feature.Features;
 import org.apache.maven.lifecycle.LifecycleExecutionException;
 import org.apache.maven.lifecycle.LifecycleNotFoundException;
 import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
@@ -80,7 +82,6 @@ public class BuilderCommon
     @Inject
     private Logger logger;
 
-
     public BuilderCommon()
     {
     }
@@ -105,6 +106,25 @@ public class BuilderCommon
 
         lifecycleDebugLogger.debugProjectPlan( project, executionPlan );
 
+        // With Maven 4's build/consumer the POM will always rewrite during distribution.
+        // The maven-gpg-plugin uses the original POM, causing an invalid signature.
+        // Fail as long as there's no solution available yet
+        if ( Features.buildConsumer().isActive() )
+        {
+            Optional<MojoExecution> gpgMojo = executionPlan.getMojoExecutions().stream()
+                            .filter( m -> "maven-gpg-plugin".equals( m.getArtifactId() ) 
+                                       && "org.apache.maven.plugins".equals( m.getGroupId() ) )
+                            .findAny();
+
+            if ( gpgMojo.isPresent() )
+            {
+                throw new LifecycleExecutionException( "The maven-gpg-plugin is not supported by Maven 4."
+                    + " Verify if there is a compatible signing solution,"
+                    + " add -D" + Features.buildConsumer().propertyName() + "=false"
+                    + " or use Maven 3." );
+            }
+        }
+
         if ( session.getRequest().getDegreeOfConcurrency() > 1 )
         {
             final Set<Plugin> unsafePlugins = executionPlan.getNonThreadSafePlugins();
diff --git a/maven-model-builder/src/main/java/org/apache/maven/feature/Features.java b/maven-model-builder/src/main/java/org/apache/maven/feature/Features.java
index 0387163..f060ef9 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/feature/Features.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/feature/Features.java
@@ -47,16 +47,24 @@ public final class Features
     public static class Feature
     {
         private final boolean active;
+        
+        private final String name;
 
         Feature( String name, String defaultValue )
         {
-            active = "true".equals( System.getProperty( name, defaultValue ) );
+            this.name = name;
+            this.active = "true".equals( System.getProperty( name, defaultValue ) );
         }
 
         public boolean isActive()
         {
            return active;
         }
+        
+        public String propertyName()
+        {
+            return name;
+        }
 
     }