autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.66k stars 116 forks source link

#1114 print build path in projectHealth #1178

Closed seregamorph closed 1 month ago

seregamorph commented 2 months ago

Solves #1114 (only projectHealth, but not buildHealth). Prints absolute path of according build.gradle of the project module. This can be pretty helpful in large multi-module projects, especially when there is no full matching between module name and submodule directory.

Sample task output:

> Task :utilities:projectHealth
/Users/morph/Projects/demo-gradle-multi-module/utilities/build.gradle
Unused dependencies which should be removed:
  testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'

Using absolute path

The absolute path is printed intentionally as it seems to be the best trade-off. This path is recognized in IDEA to open file in "Navigate to File...":

Screenshot 2024-04-27 at 19 25 50

For instance, if relative path is used, there can be ambiguity:

Screenshot 2024-04-27 at 19 26 10

Also, the relative path is not always in parent directory (for included builds) and printing "../../parent/build.gradle" will not help navigating to the file in the IDE.

seregamorph commented 2 months ago

I've updated the implementation moving the gradle file name prepending to ProjectHealthTask not to cache the GenerateProjectHealthReportTask output with absolute path (while it's not a task input).

seregamorph commented 1 month ago

I only worry about it being inconsistent with how buildHealth works

What would you prefer - address both projectHealth and buildHealth in scope of a single PR or implement them separately? The problem here is that these two tasks have different ways to aggregate and format reports.