mirror of https://github.com/apache/maven.git
reduce the code duplication of the injection
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@168052 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e0b032ac0a
commit
19d96b6163
|
@ -35,6 +35,7 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
|||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.injection.ModelDefaultsInjector;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
@ -69,6 +70,8 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
private PluginManager pluginManager;
|
||||
|
||||
private ModelDefaultsInjector modelDefaultsInjector;
|
||||
|
||||
private List phases;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -196,33 +199,17 @@ public class DefaultLifecycleExecutor
|
|||
project.addPlugin( plugin );
|
||||
}
|
||||
|
||||
// TODO: shouldn't have to call all the time
|
||||
modelDefaultsInjector.injectDefaults( project.getModel() );
|
||||
|
||||
// TODO: remove - should discover the version
|
||||
plugin = findPlugin( project.getPlugins(), groupId, artifactId );
|
||||
if ( plugin.getVersion() == null )
|
||||
{
|
||||
while ( project != null )
|
||||
{
|
||||
PluginManagement pluginManagement = project.getPluginManagement();
|
||||
|
||||
if ( pluginManagement != null )
|
||||
{
|
||||
Plugin management = findPlugin( pluginManagement.getPlugins(), groupId, artifactId );
|
||||
if ( management != null && management.getVersion() != null )
|
||||
{
|
||||
plugin.setVersion( management.getVersion() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
project = project.getParent();
|
||||
}
|
||||
|
||||
if ( plugin.getVersion() == null )
|
||||
{
|
||||
// TODO: this has probably supplanted the default in the plugin manager
|
||||
plugin.setVersion( PluginDescriptor.getDefaultPluginVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Plugin findPlugin( List plugins, String groupId, String artifactId )
|
||||
{
|
||||
Plugin plugin = null;
|
||||
|
|
|
@ -54,6 +54,9 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.plugin.PluginManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
<configuration>
|
||||
<!-- START SNIPPET: lifecyle -->
|
||||
|
|
Loading…
Reference in New Issue