[MNG-4586] Plugin prefix can't be resolved from plugin management if management entry is missing plugin version

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@921932 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-03-11 16:49:08 +00:00
parent c5e7758e3e
commit d946c8cbe9
1 changed files with 23 additions and 0 deletions

View File

@ -54,6 +54,7 @@ import org.apache.maven.lifecycle.mapping.LifecycleMapping;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.plugin.InvalidPluginDescriptorException;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
@ -860,6 +861,8 @@ public class DefaultLifecycleExecutor
{
// "pluginPrefix:goal" or "groupId:artifactId[:version]:goal"
resolveMissingPluginVersions( session.getTopLevelProject(), session );
MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, session.getTopLevelProject() );
boolean aggregating = mojoDescriptor.isAggregator() || !mojoDescriptor.isProjectRequired();
@ -1741,6 +1744,8 @@ public class DefaultLifecycleExecutor
private void resolveMissingPluginVersions( MavenProject project, MavenSession session )
throws PluginVersionResolutionException
{
Map<String, String> versions = new HashMap<String, String>();
for ( Plugin plugin : project.getBuildPlugins() )
{
if ( plugin.getVersion() == null )
@ -1748,6 +1753,24 @@ public class DefaultLifecycleExecutor
PluginVersionRequest request = new DefaultPluginVersionRequest( plugin, session );
plugin.setVersion( pluginVersionResolver.resolve( request ).getVersion() );
}
versions.put( plugin.getKey(), plugin.getVersion() );
}
PluginManagement pluginManagement = project.getPluginManagement();
if ( pluginManagement != null )
{
for ( Plugin plugin : pluginManagement.getPlugins() )
{
if ( plugin.getVersion() == null )
{
plugin.setVersion( versions.get( plugin.getKey() ) );
if ( plugin.getVersion() == null )
{
PluginVersionRequest request = new DefaultPluginVersionRequest( plugin, session );
plugin.setVersion( pluginVersionResolver.resolve( request ).getVersion() );
}
}
}
}
}