[
https://issues.apache.org/jira/browse/MNG-5965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16073871#comment-16073871
]
ASF GitHub Bot commented on MNG-5965:
-------------------------------------
GitHub user dbmeneses opened a pull request:
https://github.com/apache/maven/pull/125
[MNG-5965] Parallel build multiplies work if multiple goals are given
This p/r should also fix MNG-5705.
When multiple tasks are given so that they are grouped in different task
segments, the MultiThreadedBuilder fails.
The reason is that it creates project segments, which is a set of unique
pairs of (module, task).
It then handles each task separately, and it will schedules the build of
the task for **all** root module in those pairs, instead of scheduling only the
root module which are associated with that particular task.
Example, given the project with the following hierarchy of modules:
```
root
-- module1
```
If we run `mvn task1 task2`, being task2 an aggregating task, we get the
following project segments:
(task1, root), (task1, module1), (task2, root).
The MultiThreadedBuilder will first handle task1, and will schedule the
build of: (task1, root), (task1, root).
Each of these builds will then recursively build it's children, meaning
that _task1 will be executed twice for every module in the project_.
This fix changes the builder so that it considers the project segments of
each task segment separately, by creating a ConcurrencyDependencyGraph for each
task segment.
I believe that MNG-5705 is a consequence of the same problem, because the
builder will not count correctly the number of projects that are built because
of the shared ConcurrencyDependencyGraph, resulting in a NPE.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dbmeneses/maven master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/maven/pull/125.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #125
----
commit 9518bb247bb5c9dbc267cdaa3407618178aad1f4
Author: Duarte Meneses <[email protected]>
Date: 2017-07-04T15:33:10Z
[MNG-5965] Parallel build multiplies work if multiple goals are given
----
> Parallel build multiplies work if multiple goals are given
> ----------------------------------------------------------
>
> Key: MNG-5965
> URL: https://issues.apache.org/jira/browse/MNG-5965
> Project: Maven
> Issue Type: Bug
> Components: Bootstrap & Build
> Affects Versions: 3.3.9
> Environment: Windows 7 64bit
> Reporter: Matthias Schmalz
> Attachments: parallel.test.zip
>
>
> When I run a parallel build which invokes multiple goals Maven multiplies the
> work e.g. when I run
> install sonar:sonar
> Every phase is executed once as expected. However when I run
> install sonar:sonar -T 4
> Every phase is executed twice.
> The problem can be reproduced with a single simple Java project (of course
> parallel builds are useless with a single module). Debugging showed that
> every Mojo is really called twice per project.
> Find attached a simple project and two build outputs, where you can see that
> the parallel build is doing everything twice (you can ignore that Sonar fails
> in the end, due to no server is up).
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)