runningcode / gradle-doctor

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

Possibly false positive or a misleading message "Gradle is not using JAVA_HOME" if JAVA_HOME is a symlink #367

Open climategadgets opened 1 month ago

climategadgets commented 1 month ago

Action Taken

./gradlew build

Expected Result

Build passes without Gradle Doctor warnings

Actual Result

Gradle doctor issues the following message (on both first and subsequent daemon runs):

=============================== Gradle Doctor Prescriptions ============================================
| Gradle is not using JAVA_HOME.                                                                       |
| JAVA_HOME is /opt/homebrew/opt/openjdk@17                                                            |
| Gradle is using /opt/homebrew/Cellar/openjdk@17/17.0.12/libexec/openjdk.jdk/Contents/Home            |
| This can slow down your build significantly when switching from Android Studio to the terminal.      |
| To fix: Project Structure -> JDK Location.                                                           |
| Set this to your JAVA_HOME.                                                                          |
|                                                                                                      |
========================================================================================================

Additional Information

OS version: Sonoma 14.5 Gradle version: 8.7 Gradle Doctor version: 0.9.2, 0.10.0 JDK installation method: Homebrew Multiple Gradle daemons are not started during subsequent runs

Additional Considerations

There are two options: either Gradle itself realizes it is possible to have symlinks to the same final location and starts one daemon per actual JDK, or it doesn't. In the former case the problem lies with Gradle Doctor and its logic should be adjusted to recognize the situation, in the latter with Gradle and then there's one recourse short of fixing the issue in Gradle, and that is - change the message to explain to the user what is going on. The way the warning is currently worded does not suggest this particular problem is recognized, even though it is technically correct.

Related Issues

It looks like something similar was already reported in #187.

runningcode commented 1 month ago

Thanks for filing. Are you getting multiple Gradle Daemons started in this case? What do you think is a good approach to solving this? I'm open to PRs.

climategadgets commented 1 month ago

(updated the original submission) no, multiple Gradle daemons are not started.

Approach - the message seems to be simply a false positive (having just one daemon would make me think that Gradle is aware of this); if Gradle Doctor supports multiple severities it would be a good candidate to push the level down and make it not show up unless run with --debug (and rephrase the message).

Side note, To fix: Project Structure -> JDK Location suggestion is only pertinent to IDE users, though this was observed on a command line. Moreover, it seems to be IntelliJ specific.