autonomousapps / autonomousapps/dependency-analysis-gradle-plugin

Internal defaulted constructor parameter makes the dependency `api` if another parameter is a value class

Open
#1,394 2 comments 0 reactions 0 assignees View on GitHub
bug toolchain:kotlin
Dominant language
Kotlin
Stars
2.2k
Forks
158
Avg merge
16h 25m
Merged PRs (30d)
46

Description

**Build scan link**
https://gradle.com/s/jcmca6qg7cvfs

**Plugin version**
2.10.1

**Gradle version**
8.13

**JDK version**
21

**(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version**
2.1.10

**(Optional) `reason` output for bugs relating to incorrect advice**
```
------------------------------------------------------------
You asked about the dependency 'org.slf4j:slf4j-api:1.7.10'.
You have been advised to change this dependency to 'api' from 'implementation'.
------------------------------------------------------------

Shortest path from root project to org.slf4j:slf4j-api:1.7.10 for compileClasspath:
:
\--- org.slf4j:slf4j-api:1.7.10

Shortest path from root project to org.slf4j:slf4j-api:1.7.10 for runtimeClasspath:
:
\--- org.slf4j:slf4j-api:1.7.10

Shortest path from root project to org.slf4j:slf4j-api:1.7.10 for testCompileClasspath:
:
\--- org.slf4j:slf4j-api:1.7.10

Shortest path from root project to org.slf4j:slf4j-api:1.7.10 for testRuntimeClasspath:
:
\--- org.slf4j:slf4j-api:1.7.10

Source: main
------------
* Exposes 1 class: org.slf4j.Logger (implies api).

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

**Describe the bug**

A dependency exposed in an `internal` constructor as a defaulted parameter is incorrectly seen as part of the module's public API, _if another dependency is an `@JvmInline value class`_.

**To Reproduce**

Steps to reproduce the behaviour:
1. `git clone git@github.com:Mahoney-bug-examples/build-health-reproducer.git`
2. `cd build-health-reproducer`
3. `./gradlew buildHealth`

**Expected behavior**

The build should pass.

**Additional context**

In the reproducer project, change `dependency: Dependency` to `dependency: String` in the internal constructor of `Service` and you will see that the plugin correctly considers slf4j to be an implementation dependency.

Contributor guide

Open the contributing guide

Research direction

Start with the linked build-health reproducer and run ./gradlew buildHealth. Compare the internal Service constructor using dependency: Dependency with the version using dependency: String, then trace the dependency analysis that reports slf4j-api as api. Done means the reproducer build passes and slf4j-api is correctly considered an implementation dependency.

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
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.