autonomousapps / autonomousapps/dependency-analysis-gradle-plugin
False positive incorrect configuration on value class in public API
- Dominant language
- Kotlin
- Stars
- 2.2k
- Forks
- 158
- Avg merge
- 16h 25m
- Merged PRs (30d)
- 46
Description
**Plugin version**
3.5.1
**Gradle version**
9.3.1
**JDK version**
23
**(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version**
2.3.0
**(Optional) Android Gradle Plugin (AGP) version**
9.0.0
**(Optional) `reason` output for bugs relating to incorrect advice**
```
> Task :data:auth:public:reason
------------------------------------------------------------
You asked about the dependency ':entity:common'.
You have been advised to change this dependency to 'implementation' from 'api'.
------------------------------------------------------------
Shortest path from :data:auth:public to :entity:common for debugCompileClasspath:
:data:auth:public
\--- :entity:common
Shortest path from :data:auth:public to :entity:common for debugRuntimeClasspath:
:data:auth:public
\--- :entity:common
Shortest path from :data:auth:public to :entity:common for debugUnitTestCompileClasspath:
:data:auth:public
\--- :entity:common
Shortest path from :data:auth:public to :entity:common for debugUnitTestRuntimeClasspath:
:data:auth:public
\--- :entity:common
Shortest path from :data:auth:public to :entity:common for debugAndroidTestCompileClasspath:
:data:auth:public
\--- :entity:common
Shortest path from :data:auth:public to :entity:common for debugAndroidTestRuntimeClasspath:
:data:auth:public
\--- :entity:common
Source: debug, android_test
---------------------------
(no usages)
Source: debug, main
-------------------
* Uses 1 class: com.superdo.entity.common.ids.UserId (implies implementation).
Source: debug, test
-------------------
(no usages)
```
**Describe the bug**
I have the following class in `:entity:common`:
```kotlin
@Serializable
@JvmInline
value class UserId(val raw: String)
```
In `:data:auth:public:` I have a class that has a property with a type of `UserId`:
```kotlin
data class User(
val id: UserId,
val email: String,
val name: String,
val createdAt: Long,
)
```
I add a dependency to `:entity:common`:
```kotlin
dependencies {
api(projects.entity.common)
}
```
and get an incorrect configuration warning, saying I should be using `implementation`.
If I change `UserId` to not be a `value class`, then it works fine.
**To Reproduce**
I can make a repro project if needed, I'm just being lazy at the moment.
Contributor guide
Research direction
No source files or tests are named; start by examining the public API dependency analysis that produces the shown `reason` output for Kotlin `@JvmInline` value classes. Reproduce the `UserId` and `User` setup, then verify that the advice no longer incorrectly recommends changing `api` to `implementation`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100