`@Provides` parameters from Hilt module bindings are incorrectly classified as api
Plugin version 3.1.0
Gradle version 9.1.0
JDK version 25
(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version 2.2.20
(Optional) Android Gradle Plugin (AGP) version 8.13.0
(Optional) reason output for bugs relating to incorrect advice
./gradlew :Repositories:MyRepository:reason --id="com.squareup.retrofit2:retrofit"
...
Source: debug, main
-------------------
* Exposes 1 class: retrofit2.Retrofit (implies api).
* Imports 1 inline member: retrofit2.create (implies implementation).
* ...
Describe the bug
DAGP thinks retrofit2.Retrofit is exposed and therefore implies api while the declaration uses internal modifier.
To Reproduce
@Module
@InstallIn(ViewModelComponent::class)
internal object MyRepositoryModule {
@Provides
internal fun providesApiService(retrofit: Retrofit): MyApiService = retrofit.create()
}
Expected behavior
Classification should be implementation.
Could this be because of the public static functions in Hilt generated code?
If so, abi { exclusions { ignoreGeneratedCode() } } does not seem to get rid of it.
Thanks for the issue. It very well may be due to the generated code. Could you provide a minimal reproducer?
Here is a reproducer: https://github.com/SimonMarquis/DAGP-1574
gradlew buildHealth
Advice for :feature
These transitive dependencies should be declared directly:
api(libs.dagger)
Existing dependencies which should be modified to be as indicated:
api(project(":lib")) (was implementation)
gradlew :feature:reason --id ":lib"
------------------------------------------------------------
You asked about the dependency ':lib'.
You have been advised to change this dependency to 'api' from 'implementation'.
------------------------------------------------------------
[...]
Source: main
------------
* Exposes 1 class: com.example.lib.Lib (implies api).