dependency-analysis-gradle-plugin
dependency-analysis-gradle-plugin copied to clipboard
Unused dependency false positive if Hilt Gradle Plugin is applied
Description When the Hilt Gradle Plugin is applied (Hilt can be used without the Gradle plugin, but this issue pertains to when the plugin is in use), Dependency Analysis Gradle Plugin falsely considers a project dependency unused, when in fact it is used.
In the attached sample project below, run the command ./gradlew app:projectHealth. It should succeed due to no unused dependencies, but it fails, falsely flagging :impl as unused.
If Hilt Gradle Plugin is applied is not applied, the Dependency Analysis Gradle Plugin gives correct advice.
If you run ./gradlew testReleaseUnitTest after applying the plugin's false advice, the build will fail, demonstrating that the dependency is required.
Build scan link https://gradle.com/s/k7vtaivpaxksc
Plugin version
1.13.1
Gradle version
7.5.1
Android Gradle Plugin (AGP) version
7.3.0
reason output for bugs relating to incorrect advice
> Task :app:reason
----------------------------------------
You asked about the dependency ':impl'.
You have been advised to remove this dependency from 'implementation'.
----------------------------------------
Shortest path from :app to :impl for debugCompileClasspath:
:app
\--- :impl
Shortest path from :app to :impl for debugRuntimeClasspath:
:app
\--- :impl
Shortest path from :app to :impl for debugUnitTestCompileClasspath:
:app
\--- :impl
Shortest path from :app to :impl for debugUnitTestRuntimeClasspath:
:app
\--- :impl
Shortest path from :app to :impl for releaseCompileClasspath:
:app
\--- :impl
Shortest path from :app to :impl for releaseRuntimeClasspath:
:app
\--- :impl
Shortest path from :app to :impl for releaseUnitTestCompileClasspath:
:app
\--- :impl
Shortest path from :app to :impl for releaseUnitTestRuntimeClasspath:
:app
\--- :impl
Source: debug, main
-------------------
(no usages)
Source: release, main
---------------------
(no usages)
Source: debug, test
-------------------
(no usages)
Source: release, test
---------------------
(no usages)
Describe the bug
To Reproduce Steps to reproduce the behavior:
- Run
./gradlew app:projectHealthin attached sample project
Expected behavior
Plugin does NOT advise to remove dependency :impl
Actual behavior
Plugin advises to remove :impl.
Sample project See attached.
Thanks for the report and the reproducer!
Do you know if this issue still exists in the latest version (1.24.0 at time of writing)?
I'm still having the issue with 1.24 on my project => https://github.com/simonlebras/rickandmorty/blob/main/app/build.gradle.kts#L120 (if I remove this block, the check will fail)
Unfortunately I don't have time to work on this. I have added the sponsorable label to indicate that I could shift my priorities if someone wants to sponsor the work. PRs are also welcome.
Also ran into this problem, dependency-analysis would somehow false positive with coil even after disabling hilt 🤷