Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 78530200C09 for ; Wed, 25 Jan 2017 23:40:31 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 76F00160B5D; Wed, 25 Jan 2017 22:40:31 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 474B4160B3D for ; Wed, 25 Jan 2017 23:40:30 +0100 (CET) Received: (qmail 5335 invoked by uid 500); 25 Jan 2017 22:40:28 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 5099 invoked by uid 99); 25 Jan 2017 22:40:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jan 2017 22:40:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8D6F1E080B; Wed, 25 Jan 2017 22:40:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: schulte@apache.org To: commits@maven.apache.org Date: Wed, 25 Jan 2017 22:40:31 -0000 Message-Id: <77e994bb03d44e16b6330685057c87fb@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [04/33] maven git commit: [MNG-6117] ${session.parallel} not correctly set archived-at: Wed, 25 Jan 2017 22:40:31 -0000 [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 Commit: d413296cf396d4df385d1323843f9464af0c8a3e Parents: c6c5192 Author: Guillaume Boué Authored: Sun Nov 13 22:46:18 2016 +0100 Committer: Guillaume Boué 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). + *

+ * This builder uses a number of threads equal to the minimum of the degree of concurrency (which is the thread count + * set with -T 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 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 service = new ExecutorCompletionService<>( executor ); ConcurrencyDependencyGraph analyzer = new ConcurrencyDependencyGraph( projectBuilds, session.getProjectDependencyGraph() );