You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2009/05/20 07:16:10 UTC

svn commit: r776556 - in /maven/components/branches/MNG-2766: maven-core/src/main/java/org/apache/maven/lifecycle/ maven-core/src/test/java/org/apache/maven/lifecycle/ maven-embedder/src/main/java/org/apache/maven/embedder/execution/

Author: jvanzyl
Date: Wed May 20 05:16:09 2009
New Revision: 776556

URL: http://svn.apache.org/viewvc?rev=776556&view=rev
Log:
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.

Modified:
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
    maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=776556&r1=776555&r2=776556&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Wed May 20 05:16:09 2009
@@ -462,7 +462,7 @@
             // 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 @@
     
     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 @@
 
                 // We have retrieved the metadata
                 try
-                {
+                {                    
                     Metadata pluginGroupMetadata = readMetadata( destination );
                     
                     List<org.apache.maven.artifact.repository.metadata.Plugin> plugins = pluginGroupMetadata.getPlugins();

Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java?rev=776556&r1=776555&r2=776556&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java Wed May 20 05:16:09 2009
@@ -162,4 +162,15 @@
         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 );
+    }
 }

Modified: maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java?rev=776556&r1=776555&r2=776556&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java (original)
+++ maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java Wed May 20 05:16:09 2009
@@ -16,6 +16,7 @@
  */
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -57,6 +58,8 @@
     {
         pom( request, configuration );
 
+        populateDefaultPluginGroups( request, configuration );
+        
         settings( request, configuration );
 
         localRepository( request, configuration );
@@ -94,6 +97,14 @@
             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 @@
         throws MavenEmbedderException
     {
         Settings settings = request.getSettings();
-
-        request.setPluginGroups( settings.getPluginGroups() );
+        
+        request.getPluginGroups().addAll( settings.getPluginGroups() );
         
         List<org.apache.maven.settings.Profile> settingsProfiles = settings.getProfiles();