runningcode / gradle-doctor

The right prescription for your Gradle build.
http://runningcode.github.io/gradle-doctor
Apache License 2.0
736 stars 48 forks source link

False-positive multiple daemon for multiple projects #175

Closed eugene-krivobokov closed 1 year ago

eugene-krivobokov commented 2 years ago

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.

dsvoronin commented 2 years 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

runningcode commented 2 years ago

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?

eugene-krivobokov commented 2 years ago

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
runningcode commented 2 years ago

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.

eugene-krivobokov commented 2 years ago

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.