Closed eugene-krivobokov closed 1 year ago
Nice idea! I can try to add that, also #45 allow to use this check as warning only, which is somewhat better in your case
Thanks for reporting. I didn't know about user.dir
. Is it possible to check that on another java process? How would one do that?
One option is to use jcmd:
$JAVA_HOME/bin/jcmd <Gradle daemon PID> VM.system_properties
I've also found a couple of tests about user.dir
value.
Probably, they can clarify some expectations.
E.g. while building an app:
user.dir=/Users/path/to/project
But after fininshing the build it points to Gradle:
user.dir=/Users/path/to/gradle/daemon/7.2
Ah interesting. After the build completes any other build can re-use the daemon so I'm not sure this is a good solution.
In general I'm not sure if the disallowMultipleDaemons
property makes sense to use in multiple projects.
I agree.
The proposed heuristic based on user.dir
can cause false-negative results. As in any linter-like tool, false-positive looks better.
Feel free to close the issue.
The problem
I work on different Gradle projects. They run different Gradle daemon instances and this is expected.
disallowMultipleDaemons
fails in this case. As I understand this check ideologically is about multiple daemons for the same project.Proposal
Add heuristics to match daemon to a corresponding project.
Ideas
Compare
user.dir
in system properties of Gradle daemon process. It contains a path to the project.