gradle-doctor icon indicating copy to clipboard operation
gradle-doctor copied to clipboard

Wishlist: produce copypastable suggestions

Open climategadgets opened this issue 1 year ago • 2 comments

Existing Behavior

A pretty clear warning message is produced (trimmed for readability):

=============================== Gradle Doctor Prescriptions
| The following operations were slower to pull from the cache than to rerun:
| :...:generateGitProperties
| Consider disabling caching them.                                                                     |
| For more information see: https://runningcode.github.io/gradle-doctor/slower-from-cache/

Desired Behavior

It would be nice if the output contained a block of code that could be directly copypasted into the Gradle build file, to save an extra step of figuring out intermediaries (in this case, <taskname>, but other prescriptions will have different targets that are likely already available to Gradle Doctor internally).

climategadgets avatar Apr 18 '24 00:04 climategadgets

That sounds great. Do you have a suggestion on how can this be achieved?

runningcode avatar Apr 18 '24 13:04 runningcode

Well... Let me see:

  • Gradle Doctor is already able to figure out which component is misbehaving (generateGitProperties), and how exactly (faster to rerun than to extract from the cache)
  • I don't know enough about Gradle to be 100% sure, but I would guess that there's a short traversable path from the user visible task name to its class, GenerateGitPropertiesTask
  • The solution is already documented at https://runningcode.github.io/gradle-doctor/slower-from-cache/

It should be simple, then, to modify the prescription so it reads something like this:

| The following operations were slower to pull from the cache than to rerun:
| :...:generateGitProperties| Consider disabling caching them.
| Add this block into your Gradle build file to achieve this:
tasks.named("<GenerateGitPropertiesTask>").configure {
    outputs.cacheIf { false }
}
| For more information see: https://runningcode.github.io/gradle-doctor/slower-from-cache/

Does that sound right?

climategadgets avatar Apr 18 '24 21:04 climategadgets