i've played with the DefaultLifecycleExecutor and DefaultPluginManager a bit
and tried to separate the preparation phase from the actual mojo executions.
The preparations seem to attribute to astonishing 90% of the build
execution.
See http://picasaweb.google.com/mkleint/Maven/photo#5146520463951211778

what have I actually done? (patch attached, I hope it gets through)

in the preparation phase
1. iterate all the projects, figure out the mojo bindings.
2. for each binding, load the asociated plugin
3. for each project figure out what the required maximum project dependency
resolution is and resolve it.

in the execution phase actually just run the mojo's execute method. (ripped
the project dependency resolution from there)

The work i've done is probably not generally useful,  but it clearly shows
where space for improvements is.
However I'd like to use this in the Netbeans IDE, to "preload" various
actions as the user edits the files, so that the build/run/debug cycle gets
faster (as I'm dependent on running maven goals on these actions) and when
the user actually triggers "Run" only the execution phase needs to be run.

Milos


On Dec 19, 2007 10:34 PM, Jason van Zyl <[EMAIL PROTECTED]> wrote:

>
> On 19 Dec 07, at 12:28 PM 19 Dec 07, Milos Kleint wrote:
>
> > here is the actual screenshot.
> >
> > http://picasaweb.google.com/mkleint/Maven
> >
> > more inline..
> >
> > On Dec 19, 2007 9:19 PM, Jason van Zyl <[EMAIL PROTECTED]> wrote:
> >
> >>
> >> On 19 Dec 07, at 11:10 AM 19 Dec 07, Milos Kleint wrote:
> >>
> >>> Hello,
> >>>
> >>> i've started building my project with current 2.1-SNAPSHOT trunk and
> >>> I noticed the build is taking more time than before. I did a bit of
> >>> profiling.
> >>> I've executed "mvn install" on a set of 24 projects, all build
> >>> before, right before the profiling test.
> >>>
> >>> What struck me is that half of the time seems to be spent in
> >>> DefaultPluginManager.resolveTransitiveDependencies(). See attached
> >>> picture from netbeans profiler.
> >>> It was executed 82 times.  I suppose the root of the problem will be
> >>> somewhere much deeper and I guess there's a way to optimize the
> >>> number of calls to the method as well.
> >>> After a bit of debugging i figured that for a single project this
> >>> method is called multiple times during execution. First the
> >>> "compile" scope is resolved, later "runtime" or "test" eventually
> >>> (depends on actual plugins bound to the project)
> >>> Ideally it should be called 24 times max as far as I understand the
> >>> problem. The BuildPlan should know up front what mojos will be
> >>> executed and what is the maximum level or dependency resolution  for
> >>> the given project.
> >>>
> >>> Agreed? Is that something that I should pursue further or am I on
> >>> the wrong track?
> >>>
> >>
> >> Sure, take a look but in the plugin manager I started ripping out all
> >> the optimizations after ripping out a bunch of other code. But narrow
> >> it down for one build where
> >>
> >> 1) You don't have anything downloaded i.e. a clean repository, and
> >> 2) Where you have all the dependencies downloaded
> >>
> >> For one pass it shouldn't be resolving more then once for each
> >> plugin.
> >> I wouldn't try to start caching anything but if you're seeing more
> >> then one call per plugin then something needs to be reworked.
> >
> >
> > well, from what I understand I see 1 resolution per plugin per
> > project, if
> > the plugin requires dependency resolution.
>
> Yes, this is a reactor this is to account for cases where you may have
> the same plugin used, but might have dependencies stated itself which
> can change things so you need to track this. The non-optimized version
> obviously deals with this but you will end up with a case where
> different plugin declarations have slightly different dependency
> requirements. John tried to account for everything, but we could still
> cache most of the information.
>
> >
> > my ''optimization'' involves looking up front what is the maximum
> > dependency
> > resolution scope and resolve it just once per project. In your case
> > 1 it
> > means more than necessary gets downloaded upfront probably, but case 2
> > should be faster.
>
> So we can sync up here as I'm remaking the project builder and trying
> to setup a listener that can watch for things as projects are being
> built. One of the things I'm trying to collect are profiles and
> extensions so that we don't have to scan the POMs again after they are
> built. We could do the same with plugin declarations so that up-front
> you would know what you needed. So you could see that for all the
> plugin configurations there were no variations, pick off which ones
> need resolution, do that and then fire the build.
>
> So if you could determine what information you needed up front I can
> factor that in, and in the short term you can take the approach John
> has made with things like the extension scanner. But ultimately we
> should not need to read any pom.xml file more then once. Whether it
> come in the maven-artifact, the project builder or anything else.
>
> >
> >
> > Milos
> >
> >
> >>
> >>
> >>> Milos
> >>>
> >>> PS: If anyone is interested I can send the actual netbeans profiler
> >>> dump files for browsing (via private email).
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >> Thanks,
> >>
> >> Jason
> >>
> >> ----------------------------------------------------------
> >> Jason van Zyl
> >> Founder,  Apache Maven
> >> jason at sonatype dot com
> >> ----------------------------------------------------------
> >>
> >> believe nothing, no matter where you read it,
> >> or who has said it,
> >> not even if i have said it,
> >> unless it agrees with your own reason
> >> and your own common sense.
> >>
> >> -- Buddha
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
>
> Thanks,
>
> Jason
>
> ----------------------------------------------------------
> Jason van Zyl
> Founder,  Apache Maven
> jason at sonatype dot com
> ----------------------------------------------------------
>
> What matters is not ideas, but the people who have them. Good people
> can fix bad ideas, but good ideas can't save bad people.
>
> -- Paul Graham
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /home/mkleint/src/maven-trunks/components/maven-core
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
--- src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Base (BASE)
+++ src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Locally Modified (Based On LOCAL)
@@ -56,9 +56,15 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Stack;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.plugin.DefaultPluginManager;
 
 /**
  * @author Jason van Zyl
@@ -83,6 +89,13 @@
 
     private MojoBindingFactory mojoBindingFactory;
 
+    protected ArtifactFactory artifactFactory;
+
+    protected ArtifactResolver artifactResolver;
+
+    protected ArtifactMetadataSource artifactMetadataSource;
+    
+
     // this is needed for setting the lookup realm before we start building a project.
     private PlexusContainer container;
 
@@ -144,14 +157,52 @@
 //                e );
 //        }
 
+        prepareTaskSegments(
+            taskSegments,
+            reactorManager,
+            session,
+            rootProject,
+            dispatcher );
+        
         executeTaskSegments(
             taskSegments,
             reactorManager,
             session,
             rootProject,
             dispatcher );
+        
     }
 
+    private MojoExecution checkResolution(MojoExecution required, MojoExecution current) {
+        if ( required == null || required.getMojoDescriptor().isDependencyResolutionRequired() == null ) {
+            return current;
+        }
+        if (current == null && required.getMojoDescriptor().isDependencyResolutionRequired() != null ) {
+            return required;
+        }
+        String r = required.getMojoDescriptor().isDependencyResolutionRequired();
+        String c = current.getMojoDescriptor().isDependencyResolutionRequired();
+        int req = "compile".equals(r) ? 0 : ("runtime".equals(r) ? 1 : 2);
+        int curr = "compile".equals(c) ? 0 : ("runtime".equals(c) ? 1 : 2);
+        return req > curr ? required : current;
+    }
+
+    private void doPluginExecute(MojoExecution mojoExecution, MavenSession session, MavenProject project ) throws MojoFailureException, LifecycleExecutionException {
+        try {
+            pluginManager.executeMojo(project, mojoExecution, session);
+        } catch (PluginManagerException e) {
+            throw new LifecycleExecutionException("Internal error in the plugin manager executing goal '" + mojoExecution.getMojoDescriptor().getId() + "': " + e.getMessage(), project, e);
+        } catch (ArtifactNotFoundException e) {
+            throw new LifecycleExecutionException(e.getMessage(), project, e);
+        } catch (InvalidDependencyVersionException e) {
+            throw new LifecycleExecutionException(e.getMessage(), project, e);
+        } catch (ArtifactResolutionException e) {
+            throw new LifecycleExecutionException(e.getMessage(), project, e);
+        } catch (PluginConfigurationException e) {
+            throw new LifecycleExecutionException(e.getMessage(), project, e);
+        }
+    }
+
     private void executeTaskSegments( final List taskSegments,
                                       final ReactorManager reactorManager,
                                       final MavenSession session,
@@ -195,29 +246,19 @@
                     {
                         session.setCurrentProject( rootProject );
 
-                        // NEW: Build up the execution plan, including configuration.
-                        List mojoBindings = getLifecycleBindings(
-                            segment.getTasks(),
-                            rootProject,
-                            session,
-                            target );
+                        List mojoExecutions = segment.getExecutions( rootProject );
 
-                        // NEW: Then, iterate over each binding in that plan, and execute the associated mojo.
-                        // only call once, with the top-level project (assumed to be provided as a parameter)...
-                        for ( Iterator mojoIterator = mojoBindings.iterator(); mojoIterator.hasNext(); )
+                        for ( Iterator mojoIterator = mojoExecutions.iterator(); mojoIterator.hasNext(); )
                         {
-                            MojoBinding binding = (MojoBinding) mojoIterator.next();
+                            MojoExecution exec = (MojoExecution) mojoIterator.next();
 
+                            MojoBinding binding = segment.getBinding( exec );
+                                
                             try
                             {
-                                executeGoalAndHandleFailures(
-                                    binding,
+                                doPluginExecute( exec, 
                                     session,
-                                    dispatcher,
-                                    event,
-                                    reactorManager,
-                                    buildStartTime,
-                                    target );
+                                                 rootProject );
                             }
                             catch ( MojoFailureException e )
                             {
@@ -300,25 +341,24 @@
                         {
                             session.setCurrentProject( currentProject );
 
-                            List mojoBindings = getLifecycleBindings(
-                                segment.getTasks(),
-                                currentProject,
-                                session,
-                                target );
+                            List mojoExecutions = segment.getExecutions( currentProject );
 
-                            for ( Iterator mojoIterator = mojoBindings.iterator(); mojoIterator.hasNext(); )
+                            for ( Iterator mojoIterator = mojoExecutions.iterator(); mojoIterator.hasNext(); )
                             {
-                                MojoBinding binding = (MojoBinding) mojoIterator.next();
+                                MojoExecution exec = (MojoExecution) mojoIterator.next();
 
+                                MojoBinding binding = segment.getBinding( exec );
+                                
                                 getLogger().debug(
                                     "Mojo: " + binding.getGoal() + " has config:\n"
                                         + binding.getConfiguration() );
 
                                 try
                                 {
-                                    executeGoalAndHandleFailures( binding, session, dispatcher,
-                                                                  event, reactorManager,
-                                                                  buildStartTime, target );
+                                    doPluginExecute( exec, 
+                                                     session, 
+                                                     currentProject );
+                                    
                                 }
                                 catch ( MojoFailureException e )
                                 {
@@ -368,6 +408,222 @@
         }
     }
 
+    private void prepareTaskSegments( final List taskSegments,
+                                      final ReactorManager reactorManager,
+                                      final MavenSession session,
+                                      final MavenProject rootProject,
+                                      final EventDispatcher dispatcher )
+        throws LifecycleExecutionException, BuildFailureException
+    {
+        for ( Iterator it = taskSegments.iterator(); it.hasNext(); )
+        {
+            TaskSegment segment = (TaskSegment) it.next();
+
+            if ( segment.aggregate() )
+            {
+                    line();
+
+                    getLogger().info( "Preparing " + rootProject.getName() );
+
+                    getLogger().info( "  " + segment );
+
+                    line();
+
+                    String target = rootProject.getId() + " ( " + segment + " )";
+
+                    getLogger().debug( "Constructing build plan for " + target );
+
+                    //TODO how to handle event dispatching in preparation phase..
+                    String event = MavenEvents.PROJECT_EXECUTION;
+
+                    long buildStartTime = System.currentTimeMillis();
+
+//                    dispatcher.dispatchStart(
+//                        event,
+//                        target );
+
+                    ClassRealm oldLookupRealm = setProjectLookupRealm( session, rootProject );
+
+                    try
+                    {
+                        session.setCurrentProject( rootProject );
+
+                        // NEW: Build up the execution plan, including configuration.
+                        List mojoBindings = getLifecycleBindings(
+                            segment.getTasks(),
+                            rootProject,
+                            session,
+                            target );
+
+                        // NEW: Then, iterate over each binding in that plan, and execute the associated mojo.
+                        // only call once, with the top-level project (assumed to be provided as a parameter)...
+                        MojoExecution resolutionExecution = null;
+                        
+                        for ( Iterator mojoIterator = mojoBindings.iterator(); mojoIterator.hasNext(); )
+                        {
+                            MojoBinding binding = (MojoBinding) mojoIterator.next();
+
+                            try
+                            {
+                                 MojoExecution ex = prepareGoal(
+                                    binding,
+                                    session,
+                                    dispatcher,
+                                    event,
+                                    reactorManager,
+                                    buildStartTime,
+                                    target );
+                                 
+                                 if ( ex != null ) 
+                                 {
+                                    resolutionExecution = checkResolution( ex, resolutionExecution ); 
+                                    segment.add( ex, binding, rootProject );
+                                 }
+                                
+                            }
+                            catch ( MojoFailureException e )
+                            {
+                                AggregatedBuildFailureException error = new AggregatedBuildFailureException(
+                                                                               session.getExecutionRootDirectory(),
+                                                                               binding,
+                                                                               e );
+
+//                                dispatcher.dispatchError( event, target, error );
+
+                                if ( handleExecutionFailure( reactorManager, rootProject, error, binding, buildStartTime ) )
+                                {
+                                    throw error;
+                                }
+                            }
+                        }
+                        if ( resolutionExecution != null ) 
+                        {
+                            checkProjectDependencyResolution( rootProject, 
+                                                              session,
+                                                              resolutionExecution.getMojoDescriptor() );
+                        }
+                    }
+                    finally
+                    {
+                        session.setCurrentProject( null );
+                        restoreLookupRealm( oldLookupRealm );
+                    }
+
+//                    dispatcher.dispatchEnd(
+//                        event,
+//                        target );
+            }
+            else
+            {
+                List sortedProjects = session.getSortedProjects();
+
+                // iterate over projects, and execute on each...
+                for ( Iterator projectIterator = sortedProjects.iterator(); projectIterator.hasNext(); )
+                {
+                    MavenProject currentProject = (MavenProject) projectIterator.next();
+
+                        line();
+
+                        getLogger().info( "Preparing " + currentProject.getName() );
+
+                        getLogger().info( "  " + segment );
+
+                        line();
+
+                        String target = currentProject.getId() + " ( " + segment + " )";
+
+                        // !! This is ripe for refactoring to an aspect.
+                        // Event monitoring.
+                        String event = MavenEvents.PROJECT_EXECUTION;
+
+                        long buildStartTime = System.currentTimeMillis();
+
+//                        dispatcher.dispatchStart(
+//                            event,
+//                            target );
+
+                        ClassRealm oldLookupRealm = setProjectLookupRealm( session, currentProject );
+
+                        try
+                        {
+                            session.setCurrentProject( currentProject );
+
+                            List mojoBindings = getLifecycleBindings(
+                                segment.getTasks(),
+                                currentProject,
+                                session,
+                                target );
+                            
+                            MojoExecution resolutionExecution = null;
+
+                            for ( Iterator mojoIterator = mojoBindings.iterator(); mojoIterator.hasNext(); )
+                            {
+                                MojoBinding binding = (MojoBinding) mojoIterator.next();
+
+                                try
+                                {
+                                    MojoExecution ex = prepareGoal( binding, session, dispatcher,
+                                                                    event, reactorManager,
+                                                                    buildStartTime, target );
+                                    
+                                    if ( ex != null ) 
+                                    {
+                                        resolutionExecution = checkResolution( ex, resolutionExecution ); 
+                                        segment.add(ex, binding, currentProject);
+                                    }
+                                }
+                                catch ( MojoFailureException e )
+                                {
+                                    ProjectBuildFailureException error = new ProjectBuildFailureException(
+                                                                                                           currentProject.getId(),
+                                                                                                           binding,
+                                                                                                           e );
+
+//                                    dispatcher.dispatchError( event, target, error );
+
+                                    if ( handleExecutionFailure( reactorManager, currentProject, error, binding, buildStartTime ) )
+                                    {
+                                        throw error;
+                                    }
+                                }
+                            }
+                            if ( resolutionExecution != null ) 
+                            {
+                                checkProjectDependencyResolution( currentProject, 
+                                                                  session,
+                                                                  resolutionExecution.getMojoDescriptor() );
+
+                            }
+                            
+                        }
+                        finally
+                        {
+                            session.setCurrentProject( null );
+                            restoreLookupRealm( oldLookupRealm );
+                        }
+
+//                        dispatcher.dispatchEnd(
+//                            event,
+//                            target );
+                }
+            }
+        }
+    }
+    
+    private void checkProjectDependencyResolution( MavenProject project, MavenSession session, MojoDescriptor descriptor ) {
+        try {
+            DefaultPluginManager.checkProjectDependencyResolution(project, descriptor, session, artifactMetadataSource, artifactResolver, artifactFactory);
+        } catch (ArtifactNotFoundException ex) {
+            ex.printStackTrace();
+        } catch (ArtifactResolutionException ex) {
+            ex.printStackTrace();
+        } catch (InvalidDependencyVersionException ex) {
+            ex.printStackTrace();
+        }
+        
+    }
+    
+
     private void restoreLookupRealm( ClassRealm oldLookupRealm )
     {
         if ( oldLookupRealm != null )
@@ -445,7 +701,7 @@
         return mojoBindings;
     }
 
-    private void executeGoalAndHandleFailures( final MojoBinding mojoBinding,
+    private MojoExecution prepareGoal(         final MojoBinding mojoBinding,
                                                final MavenSession session,
                                                final EventDispatcher dispatcher,
                                                final String event,
@@ -475,7 +731,7 @@
                 if ( mojoBinding.isOptional() )
                 {
                     getLogger().debug( "Skipping optional mojo execution: " + MojoBindingUtils.toString( mojoBinding ), e );
-                    return;
+                    return null;
                 }
                 else
                 {
@@ -493,51 +749,8 @@
                 MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
 
                 mojoExecution.setConfiguration( (Xpp3Dom) mojoBinding.getConfiguration() );
-
-                try
-                {
-                    pluginManager.executeMojo(
-                        project,
-                        mojoExecution,
-                        session );
+                return mojoExecution;
                 }
-                catch ( PluginManagerException e )
-                {
-                    throw new LifecycleExecutionException(
-                        "Internal error in the plugin manager executing goal '"
-                            + mojoDescriptor.getId() + "': " + e.getMessage(),
-                            project,
-                        e );
-                }
-                catch ( ArtifactNotFoundException e )
-                {
-                    throw new LifecycleExecutionException(
-                        e.getMessage(),
-                        project,
-                        e );
-                }
-                catch ( InvalidDependencyVersionException e )
-                {
-                    throw new LifecycleExecutionException(
-                        e.getMessage(),
-                        project,
-                        e );
-                }
-                catch ( ArtifactResolutionException e )
-                {
-                    throw new LifecycleExecutionException(
-                        e.getMessage(),
-                        project,
-                        e );
-                }
-                catch ( PluginConfigurationException e )
-                {
-                    throw new LifecycleExecutionException(
-                        e.getMessage(),
-                        project,
-                        e );
-                }
-            }
             else
             {
                 throw new LifecycleExecutionException(
@@ -547,15 +760,17 @@
         }
         catch ( LifecycleExecutionException e )
         {
-            dispatcher.dispatchError( event, target, e );
+//            dispatcher.dispatchError( event, target, e );
 
             if ( handleExecutionFailure( rm, project, e, mojoBinding, buildStartTime ) )
             {
                 throw e;
             }
         }
+        return null;
     }
 
+
     private boolean handleExecutionFailure( final ReactorManager rm,
                                             final MavenProject project,
                                             final Exception e,
@@ -772,6 +987,10 @@
 
         private final List tasks = new ArrayList();
 
+        private final Map /**<MavenProject, List<MojoExecution>*/ mojoExecutions = new HashMap();
+        
+        private final Map /** <MojoExecution, MojoBinding*/ mojoBindings = new HashMap();
+        
         TaskSegment()
         {
 
@@ -824,8 +1043,38 @@
         {
             return tasks;
         }
+        
+        void add( MojoExecution exec, MojoBinding binding, MavenProject project ) 
+        {
+            List lst = (List) mojoExecutions.get( project );
+
+            if ( lst == null ) 
+            {
+                lst = new ArrayList();
+                
+                mojoExecutions.put( project, lst);
     }
 
+            lst.add( exec );
+            
+            mojoBindings.put( exec, binding );
+        }
+        
+        List getExecutions( MavenProject project ) 
+        {
+            List lst = (List) mojoExecutions.get( project );
+            
+            return lst != null ? lst : Collections.EMPTY_LIST;
+        }
+
+        private MojoBinding getBinding( MojoExecution exec ) 
+        {
+            return (MojoBinding) mojoBindings.get( exec );
+        }
+        
+        
+    }
+
     public void contextualize( Context context )
         throws ContextException
     {
Index: src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
--- src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Base (BASE)
+++ src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Locally Modified (Based On LOCAL)
@@ -532,32 +532,8 @@
         {
             getLogger().warn( "Mojo: " + mojoDescriptor.getGoal() + " is deprecated.\n" + mojoDescriptor.getDeprecated() );
         }
+        checkDependencyResolution(project, mojoDescriptor, session, artifactMetadataSource, artifactResolver, artifactFactory);
 
-        if ( mojoDescriptor.isDependencyResolutionRequired() != null )
-        {
-            Collection projects;
-
-            if ( mojoDescriptor.isAggregator() )
-            {
-                projects = session.getSortedProjects();
-            }
-            else
-            {
-                projects = Collections.singleton( project );
-            }
-
-            for ( Iterator i = projects.iterator(); i.hasNext(); )
-            {
-                MavenProject p = (MavenProject) i.next();
-
-                resolveTransitiveDependencies( session, artifactResolver,
-                                               mojoDescriptor.isDependencyResolutionRequired(),
-                                               artifactFactory, p );
-            }
-
-            downloadDependencies( project, session, artifactResolver );
-        }
-
         String goalName = mojoDescriptor.getFullGoalName();
 
         Mojo mojo = null;
@@ -654,6 +630,49 @@
         }
     }
 
+    protected void checkDependencyResolution( MavenProject project, 
+                                                  MojoDescriptor mojoDescriptor, 
+                                                  MavenSession session, 
+                                                  ArtifactMetadataSource artifactMetadataSource, 
+                                                  ArtifactResolver artifactResolver,
+                                                  ArtifactFactory artifactFactory) 
+             throws ArtifactNotFoundException, ArtifactResolutionException, InvalidDependencyVersionException 
+    {
+//        checkProjectDependencyResolution(project, mojoDescriptor, session, artifactMetadataSource, artifactResolver, artifactFactory);
+    }
+    
+    
+    public static void checkProjectDependencyResolution( MavenProject project, 
+                                                  MojoDescriptor mojoDescriptor, 
+                                                  MavenSession session, 
+                                                  ArtifactMetadataSource artifactMetadataSource, 
+                                                  ArtifactResolver artifactResolver,
+                                                  ArtifactFactory artifactFactory) 
+             throws ArtifactNotFoundException, ArtifactResolutionException, InvalidDependencyVersionException 
+    {
+        if (mojoDescriptor.isDependencyResolutionRequired() != null) 
+        {
+            Collection projects;
+
+            if (mojoDescriptor.isAggregator()) 
+            {
+                projects = session.getSortedProjects();
+            } else 
+            {
+                projects = Collections.singleton(project);
+            }
+
+            for (Iterator i = projects.iterator(); i.hasNext();) 
+            {
+                MavenProject p = (MavenProject) i.next();
+
+                resolveTransitiveDependencies(session, artifactResolver, mojoDescriptor.isDependencyResolutionRequired(), artifactFactory, p, artifactMetadataSource);
+            }
+
+            downloadDependencies(project, session, artifactResolver);
+        }
+    }
+    
     private Plugin createDummyPlugin( PluginDescriptor pluginDescriptor )
     {
         Plugin plugin = new Plugin();
@@ -1349,11 +1368,12 @@
     // Artifact resolution
     // ----------------------------------------------------------------------
 
-    private void resolveTransitiveDependencies( MavenSession context,
+    private static void resolveTransitiveDependencies( MavenSession context,
                                                 ArtifactResolver artifactResolver,
                                                 String scope,
                                                 ArtifactFactory artifactFactory,
-                                                MavenProject project )
+                                                MavenProject project,
+                                                ArtifactMetadataSource artifactMetadataSource )
         throws ArtifactResolutionException, ArtifactNotFoundException,
         InvalidDependencyVersionException
     {
@@ -1389,7 +1409,7 @@
     // Artifact downloading
     // ----------------------------------------------------------------------
 
-    private void downloadDependencies( MavenProject project,
+    private static void downloadDependencies( MavenProject project,
                                        MavenSession context,
                                        ArtifactResolver artifactResolver )
         throws ArtifactResolutionException, ArtifactNotFoundException
Index: src/main/resources/META-INF/plexus/components.xml
--- src/main/resources/META-INF/plexus/components.xml Base (BASE)
+++ src/main/resources/META-INF/plexus/components.xml Locally Modified (Based On LOCAL)
@@ -417,6 +417,16 @@
         <requirement>
           <role>org.apache.maven.lifecycle.binding.MojoBindingFactory</role>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
+          <role-hint>default</role-hint>
+        </requirement>
       </requirements>
     </component>
 
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to