mirror of
https://github.com/apache/maven.git
synced 2025-02-22 01:45:37 +00:00
Resolving: MNG-1052
o Added pluginManagement injection to MavenProject.addPlugin(..) so that no Plugin definition added to the project can go without having managed info injected into it. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@293454 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e77ba206a9
commit
805a5952eb
@ -29,7 +29,6 @@
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.apache.maven.model.PluginManagement;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.ReportSet;
|
||||
import org.apache.maven.monitor.event.EventDispatcher;
|
||||
@ -47,7 +46,6 @@
|
||||
import org.apache.maven.plugin.lifecycle.Phase;
|
||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.injection.ModelDefaultsInjector;
|
||||
import org.apache.maven.reactor.ReactorException;
|
||||
import org.apache.maven.reporting.MavenReport;
|
||||
import org.apache.maven.settings.Settings;
|
||||
@ -82,8 +80,6 @@ public class DefaultLifecycleExecutor
|
||||
// Components
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private ModelDefaultsInjector modelDefaultsInjector;
|
||||
|
||||
private PluginManager pluginManager;
|
||||
|
||||
private ExtensionManager extensionManager;
|
||||
@ -1291,7 +1287,9 @@ else if ( numTokens == 3 || numTokens == 4 )
|
||||
}
|
||||
}
|
||||
|
||||
injectHandlerPluginConfiguration( project, plugin );
|
||||
// this has been simplified from the old code that injected the plugin management stuff, since
|
||||
// pluginManagement injection is now handled by the project method.
|
||||
project.addPlugin( plugin );
|
||||
|
||||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
||||
if ( mojoDescriptor == null )
|
||||
@ -1302,29 +1300,6 @@ else if ( numTokens == 3 || numTokens == 4 )
|
||||
return mojoDescriptor;
|
||||
}
|
||||
|
||||
private void injectHandlerPluginConfiguration( MavenProject project, Plugin plugin )
|
||||
{
|
||||
String key = plugin.getKey();
|
||||
|
||||
Plugin buildPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( key );
|
||||
|
||||
if ( buildPlugin == null )
|
||||
{
|
||||
PluginManagement pluginManagement = project.getPluginManagement();
|
||||
if ( pluginManagement != null )
|
||||
{
|
||||
Plugin managedPlugin = (Plugin) pluginManagement.getPluginsAsMap().get( key );
|
||||
|
||||
if ( managedPlugin != null )
|
||||
{
|
||||
modelDefaultsInjector.mergePluginWithDefaults( plugin, managedPlugin );
|
||||
}
|
||||
}
|
||||
|
||||
project.addPlugin( plugin );
|
||||
}
|
||||
}
|
||||
|
||||
protected void line()
|
||||
{
|
||||
getLogger().info( "----------------------------------------------------------------------------" );
|
||||
|
@ -152,9 +152,6 @@
|
||||
<requirement>
|
||||
<role>org.apache.maven.extension.ExtensionManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
|
@ -2470,6 +2470,14 @@
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>4.0.0</version>
|
||||
<code><![CDATA[
|
||||
public static final String DEFAULT_EXECUTION_ID = "default";
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
<class>
|
||||
<name>DependencyManagement</name>
|
||||
|
@ -1132,6 +1132,23 @@ public void addPlugin( Plugin plugin )
|
||||
|
||||
if ( !build.getPluginsAsMap().containsKey( plugin.getKey() ) )
|
||||
{
|
||||
PluginManagement pm = build.getPluginManagement();
|
||||
|
||||
if ( pm != null )
|
||||
{
|
||||
Map pmByKey = pm.getPluginsAsMap();
|
||||
|
||||
String pluginKey = plugin.getKey();
|
||||
|
||||
if ( pmByKey != null && pmByKey.containsKey( pluginKey ) )
|
||||
{
|
||||
Plugin pmPlugin = (Plugin) pmByKey.get( pluginKey );
|
||||
|
||||
ModelUtils.mergePluginDefinitions( plugin, pmPlugin, false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
build.addPlugin( plugin );
|
||||
build.flushPluginMap();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user