dependency-analysis-gradle-plugin icon indicating copy to clipboard operation
dependency-analysis-gradle-plugin copied to clipboard

`@Provides` parameters from Hilt module bindings are incorrectly classified as api

Open SimonMarquis opened this issue 2 months ago • 3 comments

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.

SimonMarquis avatar Oct 17 '25 13:10 SimonMarquis

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.

SimonMarquis avatar Oct 17 '25 14:10 SimonMarquis

Thanks for the issue. It very well may be due to the generated code. Could you provide a minimal reproducer?

autonomousapps avatar Oct 17 '25 18:10 autonomousapps

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).

SimonMarquis avatar Oct 21 '25 09:10 SimonMarquis