From 6fa9cf49b78f8f49b300890e57398247163a66b1 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com> Date: Fri, 26 Jul 2019 14:50:36 +0200 Subject: [PATCH] Usage of Gradle option "--parallel" should be safe 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index a2b1fd54c46..9ce55594e38 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { -- 2.39.5