diff --git a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java index f1badcf6ea..6ffcb06b82 100644 --- a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java +++ b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java @@ -22,7 +22,6 @@ package org.apache.maven.model.plugin; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -79,7 +78,7 @@ public class DefaultLifecycleBindingsInjector lifecycleModel.setBuild( new Build() ); lifecycleModel.getBuild().getPlugins().addAll( defaultPlugins ); - merger.merge( model, lifecycleModel, problems ); + merger.merge( model, lifecycleModel ); } } @@ -91,36 +90,18 @@ public class DefaultLifecycleBindingsInjector { private static final String PLUGIN_MANAGEMENT = "plugin-management"; - private static final String NO_VERSION_PLUGINS = "no-version-plugins"; - public void merge( Model target, Model source, ModelProblemCollector problems ) + public void merge( Model target, Model source ) { if ( target.getBuild() == null ) { target.setBuild( new Build() ); } - Map context = new HashMap(); - context.put( PLUGIN_MANAGEMENT, target.getBuild().getPluginManagement() ); + Map context = + Collections.singletonMap( PLUGIN_MANAGEMENT, target.getBuild().getPluginManagement() ); mergePluginContainer_Plugins( target.getBuild(), source.getBuild(), false, context ); - - @SuppressWarnings( "unchecked" ) - Collection defaultVersionPlugins = (Collection) context.get( NO_VERSION_PLUGINS ); - if ( defaultVersionPlugins != null ) - { - List plugins = new ArrayList<>( defaultVersionPlugins.size() ); - for ( Plugin p : defaultVersionPlugins ) - { - plugins.add( p.getArtifactId() ); - } - - problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.BASE ) - .setMessage( "Version not locked for default bindings plugins " + plugins - + ", you should define versions in pluginManagement section of your " - + "pom.xml or parent" ) - .setLocation( target.getLocation( "packaging" ) ) ); - } } @SuppressWarnings( { "checkstyle:methodname" } ) @@ -166,8 +147,7 @@ public class DefaultLifecycleBindingsInjector for ( Plugin managedPlugin : pluginMgmt.getPlugins() ) { Object key = getPluginKey().apply( managedPlugin ); - Plugin addedPlugin = // remove plugin only if managedPlugin defines version - ( managedPlugin.getVersion() == null ) ? added.get( key ) : added.remove( key ); + Plugin addedPlugin = added.get( key ); if ( addedPlugin != null ) { Plugin plugin = managedPlugin.clone(); @@ -176,12 +156,6 @@ public class DefaultLifecycleBindingsInjector } } } - - if ( !added.isEmpty() ) - { - // some plugins added with default version from bindings - context.put( NO_VERSION_PLUGINS, added.values() ); - } } List result = new ArrayList<>( merged.values() );