]> source.dussan.org Git - sonarqube.git/commitdiff
Usage of Gradle option "--parallel" should be safe
authorEvgeny Mandrikov <138671+Godin@users.noreply.github.com>
Fri, 26 Jul 2019 12:50:36 +0000 (14:50 +0200)
committerSonarTech <sonartech@sonarsource.com>
Fri, 26 Jul 2019 18:21:46 +0000 (20:21 +0200)
Gradle should not execute several "yarn install" in parallel,
because Yarn doesn't support concurrent access to its global cache.

"task1.mustRunAfter(task2)" ordering has an effect only when both
tasks are scheduled for execution, however currently task
":private:docs:yarn" is not executed during execution of "gradle build".
Therefore "mustRunAfter" should be established between all pairs of
"yarn install" tasks to define their total order and to prevent their
concurrent execution even in case when one or more of these tasks not
scheduled.

build.gradle

index a2b1fd54c467d6d064f6d4d1e01a55ca9f2c6917..9ce55594e387d9b0d01d4188f2fc9b73f32a66f0 100644 (file)
@@ -422,9 +422,14 @@ subprojects {
 // Yarn doesn't support concurrent access to its global cache,
 // i.e. parallel execution of several "yarn install" tasks,
 // since these tasks are independent, we can establish arbitrary total order
-// to prevent their concurrent execution:
+// to prevent their concurrent execution.
+// Note that "task1.mustRunAfter(task2)" ordering has an effect only when both
+// tasks are scheduled for execution, therefore should be established between
+// all pairs of "yarn install" tasks to define their total order and to prevent
+// their concurrent execution even in case when one or more of these tasks not
+// scheduled.
 def yarnInstallTasks = allprojects.findResults { it -> it.tasks.findByName('yarn') }
-yarnInstallTasks.eachWithIndex { it, i -> if (i > 0) it.mustRunAfter(yarnInstallTasks.get(i - 1)) }
+yarnInstallTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnInstallTasks[0..i]) }
 
 
 artifactory {