Can you stop a task from running in parallel across multiple projects

I have a task which writes to a file (via a 3rd party application)…when this task is run in parallel there is a possibility that the file will get corrupted. Is there a way to tell gradle to only run one instance of this task at a time across all the projects?

ProjA:ProblemTask ProjB:ProblemTask

IE. Don’t let ProjA:ProblemTask and ProjB:ProblemTask be running at the same time…but it’s ok if ProjA:jar and ProjB:ProblemTask are running at the same time…

The best solution would be to simply make your task thread-safe if you intend to use parallel build support. If that is not possible you could enforce task ordering.

ProblemTask.mustRunAfter ‘:ProjA:ProblemTask’