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

Incorrect advice to change configuration when @OptIn annotation is used

Open zepurplez opened this issue 2 months ago • 1 comments

Plugin version 3.4.1

Gradle version 8.13.0

JDK version 17

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version 2.1.21

(Optional) reason output for bugs relating to incorrect advice

You asked about the dependency ':lib3'.
You have been advised to change this dependency to 'implementation' from 'api'.
------------------------------------------------------------

Shortest path from :lib2 to :lib3 for compileClasspath:
:lib2
\--- :lib3

Shortest path from :lib2 to :lib3 for runtimeClasspath:
:lib2
\--- :lib3

Shortest path from :lib2 to :lib3 for testCompileClasspath:
:lib2
\--- :lib3

Shortest path from :lib2 to :lib3 for testRuntimeClasspath:
:lib2
\--- :lib3

Source: main
------------
* Imports 1 class: com.example.lib3.MyOptIn (implies implementation).

Source: test
------------
(no usages)

Describe the bug

Existing dependencies which should be modified to be as indicated:
  implementation(project(":lib3")) (was api)

The plugin suggests changing configuration from api to implementation for the module containing OptIn annotation. As a result, the compiler fails to recognize invocations of methods annotated with OptIn.

before Image

after Image

To Reproduce Execute

./gradlew :lib2:projectHealth

OptInReproducer.zip

Expected behavior Declare dependency with OptIn annotations as api or compileApi?

zepurplez avatar Nov 07 '25 11:11 zepurplez

Thanks for the issue and reproducer.

autonomousapps avatar Nov 11 '25 22:11 autonomousapps