Gradle Doctor - Qué es y cómo descargarlo

El espíritu del Doctor: Gradle Doctor es una herramienta comunitaria, diseñada para ayudar a todos los desarrolladores a mantener sus proyectos en buen estado. Los plugins: Gradle Doctor es un plugin que diagnostica problemas comunes en las configuraciones de Gradle y ofrece soluciones precisas. Su objetivo es mejorar la eficiencia de tu entorno de desarrollo. Cómo descargarlo: Añade el siguiente código a tu archivo build.gradle: plugins { id("com.osacky.doctor") version "0.7.1" } Este formato sigue la estructura que propusiste, con la información distribuida de manera clara y directa.

2: El error que encontramos

A problem occurred configuring root project 'phinal'.
Gradle Doctor Prescriptions: Gradle is not using JAVA_HOME.
Gradle is using /snap/intellij-idea-community/515/jbr.
To fix: Project Structure -> JDK Location.
Set this to your JAVA_HOME.

3: Historia del JAVA_HOME

Explicación sobre qué es JAVA_HOME y qué se necesita hacer.

if you use gradle doctor on a linux with intellij

you will get an error like this


> =============================== Gradle Doctor Prescriptions ============================================ | Gradle is not using JAVA_HOME. | | JAVA_HOME is /usr/lib/jvm/java-11-openjdk-amd64 | | Gradle is using /usr/lib/jvm/java-17-openjdk-amd64 | | 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. | | | ========================================================================================================

This gradle doctor code will crash your build until you figure out how to get gradle to use the same reference as JAVA_HOME

There is not alot of community support on this topic and

we attempted to change the JAVA_HOME in the ~/.bashrc and ~/.profile with
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 export PATH=$JAVA_HOME/bin:$PATH

We will then run the source ~/.bashrc

We will then run the source ~/.profile

this did not work. we still would get an issue from gradle doctor and the build would crash.

the issue in the error is that gradle needs to be changed. it needs to look for the correct JAVA_HOME

inside intellij you can click on the little gradle elephant in the right corner and select the corresponding preferences item from the it's menu.

Doing so will open up Build, Execution, Deployment > Build Tools > Gradle

I am still menu diving and trying to figure out the right selection to select. but in the process i learned something very important.

Gradle doctor might not be vital to our needs.

Sure we would like to be more in control of gradle and have great tooling to understand our build process better.

but there are built into gradle ways of debugging and exploring this build system.

    gradle --scan
    gradle --info
    gradle --debug
    gradle --stacktrace

You can also add logging directly in your build.gradle file using println statements.