Is there a way to check if gradle is running in da...
# plugin-development
s
Is there a way to check if gradle is running in daemon mode?
v
What for?
Basically it is always in daemon mode, the question is just whether it is a one-off daemon or a reused / reusable daemon.
👍 1
s
I have task using the worker API, and depending on whether gradle is using a reusable daemon I could choose between classloader and process isolation modes, to save time on starting a new process
v
If I were you, I wouldn't depend on that, especially if it is a published plugin. Besides that, just that it is a one-off daemon does not mean a new process needs to be started. process isolation does not mean each work item gets a new separate process. worker process can be reused for other work items with the same requirements. Also generally, don't try to micro-optimize, especially with depending on impelmentation details like this, without having a problem. 1. make things work - optimally with tests 2. make things nice by refactoring - here tests from 1. are helpful to see the refactoring does not break the logic 3. optimize things like CPU or RAM if, and only if, you have a measurable performance problem That's the same for basically any software you write. Of course some things always make sense to do like using
StringBuilder
instead of
StringBuffer
or percompiling regex
Pattern
objects, or using the task configuration avoidance APIs, and so on. But sacrificing cleanness by using internals, or depending on implementation details, or readability by using ugly but 1 picosecond faster constructs should not be done lightly without a measurable problem.
If it nees process isolation to work properly, use project isolation, if classloader isolation is enough, use classloader isolation.