Git Product home page Git Product logo

gradle-doctor's Introduction

gradle-doctor's People

Contributors

3flex avatar bigdaz avatar codefish1 avatar dependabot[bot] avatar dsvoronin avatar egorand avatar erickuck avatar eugene-krivobokov avatar gediminaszukas avatar goooler avatar justintuchek avatar kelvinharron avatar louiscad avatar ninniuz avatar rattenkrieg avatar rciovati avatar renovate[bot] avatar runningcode avatar slowpacer avatar vanniktech avatar zacsweers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradle-doctor's Issues

Java home not matching warning not displayed properly in Android Studio

Hello,

Trying out your tool (v0.6.2) in Android Studio 4.0, on Windows with the following javaHome config block:

 javaHome {
        ensureJavaHomeMatches = true
        ensureJavaHomeIsSet = true
        failOnError.set(false)
     }

And with JAVA_HOME not matching the build JDK on purpose, I get the following message:

image

If I set the failOnError flag to true, I then get a proper message that looks like this:

image

Could the slow download info point the url to blame?

Hello, I got this while running a Gradle sync:

=============================== Gradle Doctor Prescriptions ============================================
| Detected a slow download speed downloading from External Repos.                                      |
| 1.29 MB downloaded in 3.99 s                                                                         |
| Total speed from External Repos = 0.33 MB/s                                                          |
========================================================================================================

Indeed, its slow for my fiber connection and closeby Wi-Fi, but I don't know which url was slow.
Is there a way that this plugin could report the affected urls to allow for analysis?

References about memory leak

Build output

=============================== Gradle Doctor Prescriptions ============================================
| This build spent 24% garbage collecting.                                                             |
| If this is the first build with this Daemon, it likely means that this build needs more heap space.  |
| Otherwise, if this is happening after several builds it could indicate a memory leak.                |
| For a quick fix, restart this Gradle daemon. ./gradlew --stop                                        |
========================================================================================================

The phrase Otherwise, if this is happening after several builds it could indicate a memory leak. got me curious and I tried to learn about it, but I couldn't find anything about it on a google search.

It would be cool if you could give us some tips or link something about it.

Improve error message when downloading from build cache

========================================================================================================
  | Detected a slow download speed downloading from Build Cache.                                        | 
  | 7490270 bytes downloaded in 9035 ms                                                                 | 
  | Total speed from cache = 0.8095703 MB/s                                                            |  
  |========================================================================================================

Java home symlink

So I use sdkman to manage my sdk versions.

When I try to use this plugin I get:
| JAVA_HOME is /Users/e/.sdkman/candidates/java/current
| Gradle is using /Users/e/.sdkman/candidates/java/8.0.242.hs-adpt

JAVA_HOME is actually a symlink that points to the folder which is printed as used by Gradle.

Set sane thresholds for alerting users

[ ] Don't alert for build cache connection if we've downloaded less than 1MB.
[ ] Don't warn for garbage collection if build is less than 10 seconds.

Report non-incremental annotation processors

See if there is a way to detect and report on non-incremental annotation processors that were used as part of the build. Both javac and kapt.

Log example:

[WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.lifecycle.LifecycleProcessor (NON_INCREMENTAL), androidx.room.RoomProcessor (NON_INCREMENTAL).

Annotation Processor Time does not take in to account overlapping time intervals

We only know the total duration for annotation processor timings so we can't subtract overlapping time intervals like we did for remote cache connection times in #63 . If we knew the start, end times we could subtract out overlapping time intervals to get a better estimate.

We could also use the time printed to the console as the end time for kapt and calculate based on that.

Bug: Error while trying on Windows, without a good quick-fix

All I did is add this , and then trying to build:

    id "com.osacky.doctor" version "0.7.0"

This is what I get, and it thinks I should fix it using Linux/Unix commands:

A problem occurred configuring root project 'My Application'.
> =============================== Gradle Doctor Prescriptions ============================================
  | JAVA_HOME is not set.
                                                                               |
  | Please set JAVA_HOME so that switching between Android Studio and the terminal does not trigger a fu |
  | ll rebuild.
                                                                                         |
  | To set JAVA_HOME: (using bash)
                                                                      |
  | echo "export JAVA_HOME=$(/usr/libexec/java_home)" >> ~/.bash_profile
                                |
  | or `~/.zshrc` if using zsh.
                                                                         |
  |                                                                                                      |
  ========================================================================================================

image

My Application.zip

When applied from settings.gradle it fails if a project uses KAPT

Reproducer

https://github.com/CristianGM/DoctorKotlinWrapperKtIssueReproducer

Context

I want to apply the doctor plugin on all the company projects.
We have internally a setings plugins (for artifactory and gradle enterprise configuration) and a project plugin (for static analysis and conventions)

I tried to apply the doctor using the project plugin but it fails because... it checks it's applied on the root and precompiled scripts generation use a "sample" project that doens't apply it into the root projects...

Then I thought we could use the settings plugin. It works unless a subproject is using kapt.

Issue

When a subproject use kapt and the doctor plugin is applied through settings.gradle.kts the build fails with:

java.lang.ClassNotFoundException: org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapperKt
at com.osacky.doctor.DoctorPlugin$apply$2$3.invoke(DoctorPlugin.kt:93)

You can see the scan: https://scans.gradle.com/s/i6w5wqolnkiu2
And the line from the doctor that produces the error: https://github.com/runningcode/gradle-doctor/blob/master/doctor-plugin/src/main/java/com/osacky/doctor/DoctorPlugin.kt#L93

Should Gradle doctor change default Gradle features?

I started to use Gradle Doctor, thanks for working on this. I have feedback about testCaching.

Gradle Doctor disables this by default which is against the default behavior suggested by Gradle. For us this is really good feature since it speeds up test execution and feedback time. We're ok since we don't use time or any non-deterministic value in tests.

I'm actually ok since I can just enable it. I just wanted to give feedback from our perspective.

JAVA_HOME issue with Android Studio

I am experiencing this issue with AS with Gradle Doctor enabled, where I get the JAVA_HOME is not set. error when running gradle-doctor during project configuration.

The root cause seems to be Android Studio keeping a wrong value for JAVA_HOME, and I reported that here:
https://issuetracker.google.com/issues/162313337

Since Gradle Doctor's error persists after manually selecting the same path as JAVA_HOME from File -> Project Structure -> SDK Location -> JDK location in Android Studio, which should ensure that the same JDK is used for AS and terminal, I thought there might be some issue with Gradle Doctor as well, or that at least you might have some additional insight on this.

FR: Check about redundant properties

It is probably time-consuming and not worse the effort.

How about checking some redundant AGP, kotlin and maybe major annotation processor properties.

As an example - kotlin kapt is incremental now by default so having kapt.incremental.apt=true is not needed now.

about 'Disable assembling all apps in repository simultaneously'

Hi Thank you for this plugins, it works like a charm.

I have a question about "Disable assembling all apps in repository simultaneously"

Our project has a legit reason to do the ./gradlew assembleRelease which is how our CI/CD works.

But the gradle-doctor complains this and stop the building, can I have a flag or something to ignore this checking for our building flow.

Thanks

Help to update Gradle

Hello Nelson,
I have seen you talked about your project at an Android meetup in Berlin but it's the first time I take a deeper look.

There is a feature I could contribute to gradle-doctor (because I already did it here Splitties/refreshVersions#234 ) is to warn that a newer version of Gradle is available and remind people how to upgrade

You are currently running Gradle 6.1.0. 
To update to the current stable versions, run
    $ ./gradlew wrapper --gradle-version 6.6.1

Of course we could disable the warning as here
https://runningcode.github.io/gradle-doctor/configuration/

Is that something you are interested in?

Fix printout for very long tasks

> ================================================================================================================= Gradle Doctor Prescriptions ==============================================================================================================================
  | Did you really mean to run all these? [task ':application:assembleDebug', task ':playback:playback-sample:assembleDebug', task ':player:player-ui-sample:assembleDebug', task ':libs:soul:soul-sample:assembleDebug', task ':libs:uniflow:uniflow-sample:assembleDebug'] |
  | Maybe you just meant to assemble one of them? In that case, you can try                                                                                                                                                                                                  |
  |   ./gradlew application:assembleDebug                                                                                                                                                                                                                                    |
  | Or did you hit "build" in the IDE (Green Hammer)? Did you know that assembles all the code in the entire project?                                                                                                                                                        |
  | Next time try "Sync Project with Gradle Files" (Gradle Elephant with Arrow).                                                                                                                                                                                             |
  ============================================================================================================================================================================================================================================================================

Handle nested empty src directories in one pass

If a project has a source directory like: foo/bar/baz where baz is empty, bar contains only baz and nothing else, and foo contains only bar and nothing else (i.e. they are also empty aside from the empty folder they contain), this will be flagged as an empty source directory, and the suggested solution is removing foo/bar/baz. However, this only removes baz, and the next run will flag foo/bar as an empty directory and prompt you to remove bar, and so on. This means it takes a few runs to clear out all of these folders if you go purely by the doctor's orders. It would be great if the plugin could recognize the entire tree as being empty and prompt you to remove the "root" empty directory (and subfolders) in the first pass.

Logic error in RemoteCacheEstimation

I think your formula to calculate *MBSavings is incorrect, here in this code snippet:

val oneMBTime = cacheSizeMB
val twoMBTime = cacheSizeMB / 2f
val tenMBTime = cacheSizeMB / 10f

val oneMBSavings = executionTimeSec - oneMBTime
val twoMBSavings = executionTimeSec - twoMBTime
val tenMBSavings = executionTimeSec - tenMBTime

You had subtracted oneMBTime(in MB) from executionTime(in sec), which isn't mathematically valid because you had subtracted different quantities, Hence we get incorrect results

Update README?

I saw this in your talk, but I'm still confused about what this actually is. I'm having gradle speed issues and I'm curious if this is what that's for.

Add Gradle Kotlin DSL setup snippet on the website

Currently, there's a Groovy only snippet, would be great to have the setup be straightforward to Kotlin DSL users.

Also, can't the plugins DSL be used? If it can, I can submit a PR for the doc edit.

Cannot apply gradle doctor from external script?

Example: click here

We'd like to add gradle-doctor to our repo, but developers can opt-in. And when I try to move the configuration to an external script, it breaks gradle-doctor, due to this line not able to find KotlinPluginWrapper.

Is there another way to show processing time of kapt, or is there another way to apply plugin from external script?

Do file operations check not in the configuration phase

I think after the latest fix with the symlink you introduced also performance issue - the file operations are checked during the gradle configuration that is not recommended behaviour.

How about moving all checks to the execution phase?

Request: add more precise explanation of various fixes

I've found the next ones not specific enough:

  1. Doesn't say about Windows OS how to set JAVA_HOME (can be done via command line too, but would be nice to have both UI-based and command-line instructions), even though it's running on it:
A problem occurred configuring root project 'My Application'.
> =============================== Gradle Doctor Prescriptions ============================================
  | JAVA_HOME is not set.
                                                                               |
  | Please set JAVA_HOME so that switching between Android Studio and the terminal does not trigger a fu |
  | ll rebuild.
                                                                                         |
  | To set JAVA_HOME: (using bash)
                                                                      |
  | echo "export JAVA_HOME=$(/usr/libexec/java_home)" >> ~/.bash_profile
                                |
  | or `~/.zshrc` if using zsh.
                                                                         |
  |                                                                                                      |
  ========================================================================================================
  1. It doesn't say in which file to add "UseParallelGC" :
A problem occurred configuring root project 'My Application'.
> =============================== Gradle Doctor Prescriptions ============================================
  | For faster builds, use the parallel GC.                                                              |
  | Add -XX:+UseParallelGC to the org.gradle.jvmargs                                                     |
  ========================================================================================================

  1. Doesn't say where to add "doctor" exactly:
=============================== Gradle Doctor Prescriptions ============================================
| Jetifier was enabled which means your builds are slower by 4-20%.                                    |
| Here's an article to help you disable it:                                                            |
| https://adambennett.dev/2020/08/disabling-jetifier/                                                  |
|                                                                                                      |
| To disable this warning, configure the Gradle Doctor extension:                                      |
| doctor {                                                                                             |
|   warnWhenJetifierEnable.set(false)                                                                  |
| }                                                                                                    |
========================================================================================================

Remote connection measurement is inaccurate.

We are simply taking the total amount of time spent downloading divided by the total amount downloaded.
This could mean that the total amount of time spent downloading is greater than the actual build time since multiple downloads can happen in parallel.

Weird spacing in `JAVA_HOME` message

=============================== Gradle Doctor Prescriptions ============================================
|                 JAVA_HOME is not set.                                                                |
|                 Please set JAVA_HOME so that switching between Android Studio and the terminal does  |
| not trigger a full rebuild.                                                                          |
|                 To set JAVA_HOME:                                                                    |
|                 echo "export JAVA_HOME=$(/usr/libexec/java_home)" >> ~/.bash_profile                 |
========================================================================================================

Turn GradleDaemon checker to warning

This is great to know multiple daemons are run.

But often I have some incompatible runners - AS is still finishing something I want to run extra task from the console, I work on gradle upgrade, etc.

It would be great to have possibility to turn it from error to warning.

XX:+UseParallelGC to the org.gradle.jvmargs is not being picked up by Gradle Doctor

I upgraded to the latest version of gradle doctor and was met with a new error:

Add -XX:+UseParallelGC to the org.gradle.jvmargs

This is what I currently have

org.gradle.jvmargs=-Xmx2048M -XX\:MaxPermSize\=4g -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8

I changed it to

org.gradle.jvmargs=-Xmx2048M -XX\:MaxPermSize\=4g -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8 -XX:+UseParallelGC

and it still doesn't work. I am a gradle noob, but this seems like the right spot? This is in the my root gradle.properties file.

Things I tried:

  1. I thought maybe since a gradle damon is running these changes wouldn't be picked up so I stopped all gradle daemons and ran it again
  2. I tried to edit something else in this file (android.enableJetifier) and set it to false, and my build failed... so this gradle.properties file is being picked up in general.
  3. I tried to print out the args that started the jvm and got this
 /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED -Xmx8192m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /Users/coltonidle/.gradle/wrapper/dists/gradle-6.7-bin/efvqh8uyq79v2n7rcncuhu9sv/gradle-6.7/lib/gradle-launcher-6.7.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.7

But that doesn't seem right because it reports Xmx as 8192 and I have it set to 2048. So I don't know what is printing out about the instance of java running. Also, I could have sworn I was using jdk 11 not 14. Switching to 11 didn't help things.

Hope to help any way I can.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.