o put the plugin groups in the front-end request populator, the magic plugin groups are no longer buried in the core. could still be

moved from the code in the populator to a configuration file in the maven installation.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@776556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-05-20 05:16:09 +00:00
parent 9dfca575c7
commit d5459955f5
3 changed files with 32 additions and 7 deletions

View File

@ -462,7 +462,7 @@ public class DefaultLifecycleExecutor
// From the metadata stored on the server which has been created as part of a standard
// Maven plugin deployment we will find the right PluginDescriptor from the remote
// repository.
plugin = findPluginForPrefix( prefix, session );
}
else if ( numTokens == 3 || numTokens == 4 )
@ -819,20 +819,23 @@ public class DefaultLifecycleExecutor
private Map<String,Plugin> pluginPrefixes = new HashMap<String,Plugin>();
//TODO: take repo mans into account as one may be aggregating prefixes of many
//TODO: collect at the root of the repository, read the one at the root, and fetch remote if something is missing
// or the user forces the issue
public Plugin findPluginForPrefix( String prefix, MavenSession session )
throws NoPluginFoundForPrefixException
{
// [prefix]:[goal]
Plugin plugin = pluginPrefixes.get( prefix );
if ( plugin != null )
{
return plugin;
}
for ( ArtifactRepository repository : session.getCurrentProject().getRemoteArtifactRepositories() )
{
{
for ( String pluginGroup : session.getPluginGroups() )
{
// org.apache.maven.plugins
@ -862,7 +865,7 @@ public class DefaultLifecycleExecutor
// We have retrieved the metadata
try
{
{
Metadata pluginGroupMetadata = readMetadata( destination );
List<org.apache.maven.artifact.repository.metadata.Plugin> plugins = pluginGroupMetadata.getPlugins();

View File

@ -162,4 +162,15 @@ public class LifecycleExecutorTest
assertEquals( "org.apache.maven.plugins", plugin.getGroupId() );
assertEquals( "maven-resources-plugin", plugin.getArtifactId() );
}
// Prefixes
public void testFindingPluginPrefixforCleanClean()
throws Exception
{
File pom = getProject( "project-with-additional-lifecycle-elements" );
MavenSession session = createMavenSession( pom );
Plugin plugin = lifecycleExecutor.findPluginForPrefix( "clean", session );
assertNotNull( plugin );
}
}

View File

@ -16,6 +16,7 @@ package org.apache.maven.embedder.execution;
*/
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -57,6 +58,8 @@ public class DefaultMavenExecutionRequestPopulator
{
pom( request, configuration );
populateDefaultPluginGroups( request, configuration );
settings( request, configuration );
localRepository( request, configuration );
@ -94,6 +97,14 @@ public class DefaultMavenExecutionRequestPopulator
request.setBaseDirectory( new File( System.getProperty( "user.dir" ) ) );
}
}
private void populateDefaultPluginGroups( MavenExecutionRequest request, Configuration configuration )
{
List<String> pluginGroups = new ArrayList<String>();
pluginGroups.add( "org.apache.maven.plugins" );
pluginGroups.add( "org.codehaus.mojo" );
request.setPluginGroups( pluginGroups );
}
// Process plugin groups
// Get profile models
@ -102,8 +113,8 @@ public class DefaultMavenExecutionRequestPopulator
throws MavenEmbedderException
{
Settings settings = request.getSettings();
request.setPluginGroups( settings.getPluginGroups() );
request.getPluginGroups().addAll( settings.getPluginGroups() );
List<org.apache.maven.settings.Profile> settingsProfiles = settings.getProfiles();