You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sc...@apache.org on 2017/01/25 22:41:48 UTC
[04/34] maven git commit: [MNG-6117] ${session.parallel} not
correctly set
[MNG-6117] ${session.parallel} not correctly set
MultiThreadedBuilder must set parallel to true when it's using more than
1 thread to build: i.e. a degree of concurrency greater than 1 (-T) and
more than 1 project to build. Since each ProjectSegment works on a
cloned session instance (see
BuildListCalculator#calculateProjectBuilds), the flag must be also set
on each cloned session.
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/d413296c
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/d413296c
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/d413296c
Branch: refs/heads/MNG-5958-IT
Commit: d413296cf396d4df385d1323843f9464af0c8a3e
Parents: c6c5192
Author: Guillaume Bou� <gb...@apache.org>
Authored: Sun Nov 13 22:46:18 2016 +0100
Committer: Guillaume Bou� <gb...@apache.org>
Committed: Mon Jan 16 20:29:49 2017 +0100
----------------------------------------------------------------------
.../multithreaded/MultiThreadedBuilder.java | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/d413296c/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
----------------------------------------------------------------------
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 b3e35e0..f0fa2ac 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
@@ -44,7 +44,11 @@ import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
/**
- * Builds the full lifecycle in weave-mode (phase by phase as opposed to project-by-project)
+ * Builds the full lifecycle in weave-mode (phase by phase as opposed to project-by-project).
+ * <p>
+ * 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.
*
* @since 3.0
* @author Kristian Rosenvold
@@ -73,9 +77,15 @@ public class MultiThreadedBuilder
List<TaskSegment> taskSegments, ReactorBuildStatus reactorBuildStatus )
throws ExecutionException, InterruptedException
{
- ExecutorService executor =
- Executors.newFixedThreadPool( Math.min( session.getRequest().getDegreeOfConcurrency(),
- session.getProjects().size() ), new BuildThreadFactory() );
+ int nThreads = Math.min( session.getRequest().getDegreeOfConcurrency(), session.getProjects().size() );
+ boolean parallel = nThreads >= 2;
+ // Propagate the parallel flag to the root session and all of the cloned sessions in each project segment
+ session.setParallel( parallel );
+ for ( ProjectSegment segment : projectBuilds )
+ {
+ segment.getSession().setParallel( parallel );
+ }
+ ExecutorService executor = Executors.newFixedThreadPool( nThreads, new BuildThreadFactory() );
CompletionService<ProjectSegment> service = new ExecutorCompletionService<>( executor );
ConcurrencyDependencyGraph analyzer =
new ConcurrencyDependencyGraph( projectBuilds, session.getProjectDependencyGraph() );