maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r795062 - /maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
Date Fri, 17 Jul 2009 12:10:38 GMT
Author: bentmann
Date: Fri Jul 17 12:10:38 2009
New Revision: 795062

URL: http://svn.apache.org/viewvc?rev=795062&view=rev
Log:
[MNG-2576] Make Like Reactor Mode

o Restored resume-from

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=795062&r1=795061&r2=795062&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Fri
Jul 17 12:10:38 2009
@@ -22,7 +22,6 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -379,43 +378,43 @@
     {
         ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( sorter );
 
-        if ( !request.getSelectedProjects().isEmpty() )
-        {
-            File reactorDirectory = request.getPom().getParentFile().getAbsoluteFile();
-
-            Map<File, MavenProject> projectsByFile = new HashMap<File, MavenProject>();
+        Collection<MavenProject> activeProjects = sorter.getSortedProjects();
 
-            for ( MavenProject project : sorter.getSortedProjects() )
-            {
-                projectsByFile.put( project.getFile(), project );
-            }
+        File reactorDirectory = request.getPom().getAbsoluteFile().getParentFile();
 
+        if ( !request.getSelectedProjects().isEmpty() )
+        {
             List<MavenProject> selectedProjects = new ArrayList<MavenProject>(
request.getSelectedProjects().size() );
 
             for ( String selectedProject : request.getSelectedProjects() )
             {
-                File pomFile = new File( reactorDirectory, selectedProject );
+                MavenProject project = null;
 
-                if ( pomFile.isDirectory() )
+                for ( MavenProject activeProject : activeProjects )
                 {
-                    pomFile = new File( pomFile, Maven.POMv4 );
+                    if ( isMatchingProject( activeProject, selectedProject, reactorDirectory
) )
+                    {
+                        project = activeProject;
+                        break;
+                    }
                 }
 
-                MavenProject project = projectsByFile.get( pomFile );
-
                 if ( project != null )
                 {
                     selectedProjects.add( project );
                 }
                 else
                 {
-                    throw new MavenExecutionException( "Could not find project in reactor:
" + selectedProject,
-                                                       request.getPom() );
+                    throw new MavenExecutionException( "Could not find the selected project
in the reactor: "
+                        + selectedProject, request.getPom() );
                 }
             }
 
+            activeProjects = selectedProjects;
+
             boolean makeUpstream = false;
             boolean makeDownstream = false;
+
             if ( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM.equals( request.getMakeBehavior()
) )
             {
                 makeUpstream = true;
@@ -435,29 +434,74 @@
                                                    request.getPom() );
             }
 
-            Collection<MavenProject> makeProjects = new LinkedHashSet<MavenProject>(
selectedProjects );
-
             if ( makeUpstream || makeDownstream )
             {
+                activeProjects = new LinkedHashSet<MavenProject>( selectedProjects
);
+
                 for ( MavenProject selectedProject : selectedProjects )
                 {
                     if ( makeUpstream )
                     {
-                        makeProjects.addAll( graph.getUpstreamProjects( selectedProject,
true ) );
+                        activeProjects.addAll( graph.getUpstreamProjects( selectedProject,
true ) );
                     }
                     if ( makeDownstream )
                     {
-                        makeProjects.addAll( graph.getDownstreamProjects( selectedProject,
true ) );
+                        activeProjects.addAll( graph.getDownstreamProjects( selectedProject,
true ) );
                     }
                 }
             }
+        }
+
+        if ( StringUtils.isNotEmpty( request.getResumeFrom() ) )
+        {
+            String selectedProject = request.getResumeFrom();
+
+            List<MavenProject> projects = new ArrayList<MavenProject>( activeProjects.size()
);
+
+            boolean resumed = false;
+
+            for ( MavenProject project : activeProjects )
+            {
+                if ( !resumed && isMatchingProject( project, selectedProject, reactorDirectory
) )
+                {
+                    resumed = true;
+                }
+
+                if ( resumed )
+                {
+                    projects.add( project );
+                }
+            }
+
+            if ( !resumed )
+            {
+                throw new MavenExecutionException( "Could not find project to resume reactor
build from: "
+                    + selectedProject + " vs " + activeProjects, request.getPom() );
+            }
 
-            // TODO: process resume from
+            activeProjects = projects;
+        }
 
-            graph = new FilteredProjectDependencyGraph( graph, makeProjects );
+        if ( activeProjects.size() != sorter.getSortedProjects().size() )
+        {
+            graph = new FilteredProjectDependencyGraph( graph, activeProjects );
         }
 
         return graph;
     }
 
+    private boolean isMatchingProject( MavenProject project, String selector, File reactorDirectory
)
+    {
+        File selectedProject = new File( reactorDirectory, selector );
+
+        if ( selectedProject.isFile() )
+        {
+            return selectedProject.equals( project.getFile() );
+        }
+        else
+        {
+            return selectedProject.equals( project.getBasedir() );
+        }
+    }
+
 }



Mime
View raw message