autonomousapps / autonomousapps/dependency-analysis-gradle-plugin

`buildHealth` suggests moving some `commonMain` dependencies to `jvmMain`

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

Description

**Build scan link**
https://scans.gradle.com/s/xwfxeluao2vbg

**Plugin version**
3.17.0

**Gradle version**
9.6.1

**JDK version**
11

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

**(Optional) Android Gradle Plugin (AGP) version**
N/A

**(Optional) `reason` output for bugs relating to incorrect advice**

Output of `./gradlew :reason --id androidx.compose.runtime:runtime:1.11.4`:

```
> Task :reason

------------------------------------------------------------
You asked about the dependency 'androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime)'.
You have been advised to remove this dependency from 'commonMainImplementation'.
------------------------------------------------------------

Shortest path from root project to androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime) for jvmCompileClasspath:
:
\--- androidx.compose.runtime:runtime:1.11.4

Shortest path from root project to androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime) for jvmRuntimeClasspath:
:
\--- androidx.compose.runtime:runtime:1.11.4

Shortest path from root project to androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime) for jvmTestCompileClasspath:
:
\--- androidx.compose.runtime:runtime:1.11.4

Shortest path from root project to androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime) for jvmTestRuntimeClasspath:
:
\--- androidx.compose.runtime:runtime:1.11.4

Source: jvmMain
---------------
(no usages)

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

**Describe the bug**

The advice doesn't seem to make sense, since it's true that `libs.android.compose.runtime` is unnecessarily broad, it's suggesting to move the dependency to `jvmMain.dependencies` which seems incorrect.

```
Advice for root project
Unused dependencies which should be removed:
commonMain.dependencies {
implementation(libs.androidx.compose.runtime)
}

These transitive dependencies should be declared directly:
jvmMain.dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
}
```

**To Reproduce**
Steps to reproduce the behavior:
1. Checkout https://github.com/veyndan/dependency-analysis-gradle-plugin-playground/tree/1784
2. Run `./gradlew buildHealth`

**Expected behavior**
The advice should be to replace it with `org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0` _in the same source set (i.e., `commonMain`)_. Instead.

Contributor guide

Open the contributing guide

Research direction

Start by checking out the linked playground branch and running ./gradlew buildHealth, then compare the advice with ./gradlew :reason --id androidx.compose.runtime:runtime:1.11.4. Trace how the commonMain dependency and its transitive kotlinx-coroutines-core dependency produce the jvmMain recommendation. Done means the direct dependency is recommended in commonMain rather than moved to jvmMain.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
47/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.