From d946c8cbe939f8f782220bee3384d4cac740846f Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Thu, 11 Mar 2010 16:49:08 +0000 Subject: [PATCH] [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 --- .../lifecycle/DefaultLifecycleExecutor.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 7a2ed45296..994af6d661 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -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 versions = new HashMap(); + 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() ); + } + } + } } }