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 14:24:28 UTC

[maven] branch MNG-5965 updated (d92d874 -> c6bdafe)

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.


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

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d92d874)
            \
             N -- N -- N   refs/heads/MNG-5965 (c6bdafe)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:
 .../internal/builder/multithreaded/MultiThreadedBuilder.java         | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


[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 c6bdafed23f152d83d766c1ed3db8c1c4b723eb3
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   | 10 ++++++----
 .../lifecycle/internal/ConcurrencyDependencyGraphTest.java     |  2 +-
 3 files changed, 12 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..bfbfb02 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,19 @@ 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 +145,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() );