You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2018/12/26 13:04:31 UTC

[maven] branch MNG-5965 created (now d92d874)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch MNG-5965
in repository https://gitbox.apache.org/repos/asf/maven.git.


      at d92d874  [MNG-5965] Parallel build multiplies work if multiple goals are given

This branch includes the following new commits:

     new d92d874  [MNG-5965] Parallel build multiplies work if multiple goals are given

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven] 01/01: [MNG-5965] Parallel build multiplies work if multiple goals are given

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MNG-5965
in repository https://gitbox.apache.org/repos/asf/maven.git

commit d92d874a37361723a22285e7e5673f7f27f3c0c8
Author: Duarte Meneses <du...@sonarsource.com>
AuthorDate: Tue Jul 4 17:33:10 2017 +0200

    [MNG-5965] Parallel build multiplies work if multiple goals are given
    
    This closes #125
---
 .../builder/multithreaded/ConcurrencyDependencyGraph.java        | 9 +++++----
 .../internal/builder/multithreaded/MultiThreadedBuilder.java     | 9 +++++----
 .../maven/lifecycle/internal/ConcurrencyDependencyGraphTest.java | 2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ConcurrencyDependencyGraph.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ConcurrencyDependencyGraph.java
index 190e0f7..efa8c28 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ConcurrencyDependencyGraph.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ConcurrencyDependencyGraph.java
@@ -26,6 +26,7 @@ import org.apache.maven.project.MavenProject;
 
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -61,12 +62,12 @@ public class ConcurrencyDependencyGraph
     /**
      * Gets all the builds that have no reactor-dependencies
      *
-     * @return A list of all the initial builds
+     * @return A set of all the initial builds
      */
 
     public List<MavenProject> getRootSchedulableBuilds()
     {
-        List<MavenProject> result = new ArrayList<>();
+        Set<MavenProject> result = new LinkedHashSet<>();
         for ( ProjectSegment projectBuild : projectBuilds )
         {
             if ( projectDependencyGraph.getUpstreamProjects( projectBuild.getProject(), false ).isEmpty() )
@@ -74,7 +75,7 @@ public class ConcurrencyDependencyGraph
                 result.add( projectBuild.getProject() );
             }
         }
-        return result;
+        return new ArrayList<>( result );
     }
 
     /**
@@ -151,4 +152,4 @@ public class ConcurrencyDependencyGraph
         activeDependencies.removeAll( finishedProjects );
         return activeDependencies;
     }
-}
\ No newline at end of file
+}
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
index 1414a12..033a906 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
@@ -49,7 +49,7 @@ import org.codehaus.plexus.logging.Logger;
  * This builder uses a number of threads equal to the minimum of the degree of concurrency (which is the thread count
  * set with <code>-T</code> on the command-line) and the number of projects to build. As such, building a single project
  * will always result in a sequential build, regardless of the thread count.
- * </p> 
+ * </p>
  * <strong>NOTE:</strong> This class is not part of any public api and can be changed or deleted without prior notice.
  *
  * @since 3.0
@@ -87,17 +87,18 @@ public class MultiThreadedBuilder
         }
         ExecutorService executor = Executors.newFixedThreadPool( nThreads, new BuildThreadFactory() );
         CompletionService<ProjectSegment> service = new ExecutorCompletionService<>( executor );
-        ConcurrencyDependencyGraph analyzer =
-            new ConcurrencyDependencyGraph( projectBuilds, session.getProjectDependencyGraph() );
 
         // Currently disabled
         ThreadOutputMuxer muxer = null; // new ThreadOutputMuxer( analyzer.getProjectBuilds(), System.out );
 
         for ( TaskSegment taskSegment : taskSegments )
         {
+            ProjectBuildList segmentProjectBuilds = projectBuilds.getByTaskSegment( taskSegment );
             Map<MavenProject, ProjectSegment> projectBuildMap = projectBuilds.selectSegment( taskSegment );
             try
             {
+                ConcurrencyDependencyGraph analyzer = new ConcurrencyDependencyGraph( segmentProjectBuilds,
+                                                                                      session.getProjectDependencyGraph() );
                 multiThreadedProjectTaskSegmentBuild( analyzer, reactorContext, session, service, taskSegment,
                                                       projectBuildMap, muxer );
                 if ( reactorContext.getReactorBuildStatus().isHalted() )
@@ -143,7 +144,7 @@ public class MultiThreadedBuilder
                     break;
                 }
 
-                // MNG-6170: Only schedule other modules from reactor if we have more modules to build than one. 
+                // MNG-6170: Only schedule other modules from reactor if we have more modules to build than one.
                 if ( analyzer.getNumberOfBuilds() > 1 )
                 {
                     final List<MavenProject> newItemsThatCanBeBuilt =
diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ConcurrencyDependencyGraphTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ConcurrencyDependencyGraphTest.java
index 9ab0601..6118bbe 100644
--- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ConcurrencyDependencyGraphTest.java
+++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ConcurrencyDependencyGraphTest.java
@@ -53,7 +53,7 @@ public class ConcurrencyDependencyGraphTest
 
         final List<MavenProject> projectBuilds = graph.getRootSchedulableBuilds();
         assertEquals( 1, projectBuilds.size() );
-        assertEquals( A, projectBuilds.get( 0 ) );
+        assertEquals( A, projectBuilds.iterator().next() );
 
         final List<MavenProject> subsequent = graph.markAsFinished( A );
         assertEquals( 2, subsequent.size() );