diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index e1b66a32d9..7afc2d97fd 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -48,6 +49,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.lifecycle.internal.ExecutionEventCatapult; import org.apache.maven.lifecycle.internal.LifecycleStarter; +import org.apache.maven.model.Plugin; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblemUtils; import org.apache.maven.model.building.ModelSource; @@ -249,6 +251,8 @@ public class DefaultMaven return addExceptionToResult( result, e ); } + validateProjects( projects ); + // // This creates the graph and trims the projects down based on the user request using something like: // @@ -724,6 +728,37 @@ public class DefaultMaven return index; } + private void validateProjects( List projects ) + { + Map projectsMap = new HashMap(); + + for ( MavenProject project : projects ) + { + String projectKey = ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() ); + + projectsMap.put( projectKey, project ); + } + + for ( MavenProject project : projects ) + { + // MNG-1911 / MNG-5572: Building plugins with extensions cannot be part of reactor + for ( Plugin plugin : project.getBuildPlugins() ) + { + if ( plugin.isExtensions() ) + { + String pluginKey = + ArtifactUtils.key( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() ); + + if ( projectsMap.containsKey( pluginKey ) ) + { + logger.warn( project.getName() + " uses " + plugin.getKey() + + " as extensions, which is not possible within the same reactor build. This plugin was pulled from the local repository!" ); + } + } + } + } + } + private void validateActivatedProfiles( List projects, List activeProfileIds ) { Collection notActivatedProfileIds = new LinkedHashSet( activeProfileIds );