This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch MNG-7060 in repository https://gitbox.apache.org/repos/asf/maven.git
commit c1c2c9674cae1c290a14a68a394423608a6f7bca Author: rfscholte <rfscho...@apache.org> AuthorDate: Wed Dec 30 23:49:11 2020 +0100 respect build/consumer status --- .../lifecycle/internal/builder/BuilderCommon.java | 22 ++++++++++++++-------- .../java/org/apache/maven/feature/Features.java | 10 +++++++++- 2 files changed, 23 insertions(+), 9 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 b22bc94..f363be9 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 @@ -33,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; @@ -108,15 +109,20 @@ public class BuilderCommon // 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 - 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() ) + if ( Features.buildConsumer().isActive() ) { - throw new LifecycleExecutionException( "The maven-gpg-plugin is not supported by Maven 4." - + " Verify if there is a compatible signing solution or use Maven 3" ); + 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" + + " or add -D" + Features.buildConsumer().propertyName() + "=false" + + " or use Maven 3" ); + } } if ( session.getRequest().getDegreeOfConcurrency() > 1 ) 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; + } }