How does Gradle prevent 2 daemons accessing the sa...
# community-support
a
How does Gradle prevent 2 daemons accessing the same project concurrently? Or does it not? If I run
gradlew clean classes
from 2 CLIs simultaneously then 1 of them will fail with missing classes issues because the other has just wiped its compilation result. I don't actually do this but I have run a CLI command at the same time as Intellij is running a build and that has caused a failure. Is there any kind of locking based on project location?
👀 1
v
Not as far as I remember. Would maybe also be problematic as in some situations a build also wants to triggering itself using the tooling API.
a
Thanks - the tooling API is actually where I'm running into this. I had hoped that maybe the daemons took locks on the configuration cache so they didn't clash and that my hitting this was a bug.
j
AFAICT there is some locking implemented on the build cache, but it won't prevent clashes like yours on the same project. I often end up explicitly killing the IDE daemons before running CLI daemons to avoid similar issues.
v
They can use the same daemons, that wouldn't be a problem, the problem is just if two builds run at the same time and thus disturb each other, but usually this can just manually be prevented. I seldomly have problems like that. Just if I run two builds that do the same manually mostly. If there were locking it would e.g. also be hard to have Gradle run an application for example with
run
or
bootRun
and then use Gradle to recompile and then hot-swap changed classes.
But yes, cache directories and such are usually locked properly
j
it would e.g. also be hard to have Gradle run an application for example with
run
or
bootRun
and then use Gradle to recompile and then hot-swap changed classes.
In this case I would have expected the same (launched by IDE) daemon to handle background recompilation and hotswapping, does it work differently actually?
v
does it work differently actually
Definitely, that daemon is still occupied by executing the
run
or
bootRun
task and cannot do other work. So if you want to recompile while that is running, you need to do it in another daemon.
a
Thanks for the explanations/answers
👌 1