mirror of https://github.com/apache/maven.git
[MNG-7060] Let build fail fast in case any maven-gpg-plugin goal is called
This commit is contained in:
parent
538de4d192
commit
94612f96fa
|
@ -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();
|
||||
|
|
|
@ -48,9 +48,12 @@ public final class Features
|
|||
{
|
||||
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()
|
||||
|
@ -58,6 +61,11 @@ public final class Features
|
|||
return active;
|
||||
}
|
||||
|
||||
public String propertyName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue