dependency-analysis-gradle-plugin
dependency-analysis-gradle-plugin copied to clipboard
`reason` task only shows used classes if there are no exposed classes
Plugin version 1.32.0
Gradle version 8.6
JDK version 17
(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version 1.9.23
(Optional) Android Gradle Plugin (AGP) version 8.3.2
Describe the bug
I'm running the reason task to understand why modules depend on our hairball module. It will only output used classes if there are no exposed classes. Is this intended?
To Reproduce (unfortunately I have to redact specific class/module information) With an exposed class:
$ ./gradlew :feature-library:xxx:reason --id :hairball
> Task :feature-library:xxx:reason
----------------------------------------
You asked about the dependency ':hairball'.
You have been advised to change this dependency to 'api' from 'implementation'.
----------------------------------------
<clip>
Source: debug, main
-------------------
* Exposes 1 class: com.pinterest.hairball.xyz (implies api).
When I comment out the usage of the exposed class:
$ ./gradlew :feature-library:xxx:reason --id :hairball
> Task :feature-library:xxx:reason
----------------------------------------
You asked about the dependency ':hairball'.
There is no advice regarding this dependency.
----------------------------------------
<clip>
Source: debug, main
-------------------
* Uses 11 classes, 5 of which are shown: com.pinterest.xxx ... <clipped>
Expected behavior
I'd like to use this task to prioritize classes to pull out of our hairball module, but without complete information it's difficult. Is there a way to make the reason task print out everything?
Thanks for the issue! I think that was an intentional decision, but I'm not sure it's well-justified.
Yeah it seemed intentional when I looked at the code, and certainly my use case may be slightly different than what the plugin was designed to do. Perhaps if I get some time I'll see if it's possible to put this behavior behind a flag and put up a PR.
I don't know that it needs a flag. If you wanted to contribute, I think just showing both exposed and used together would be ok. Note that the list can get quite long, so I think there's already code that limits the number of classes displayed. If you wanted to see the full list, that might be something where we'd want a flag.