autonomousapps / autonomousapps/dependency-analysis-gradle-plugin
`buildHealth` suggests moving some `commonMain` dependencies to `jvmMain`
- 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
[1m------------------------------------------------------------
You asked about the dependency 'androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime)'.[0m
You have been advised to remove this dependency from '[31mcommonMainImplementation[0m'.
[1m------------------------------------------------------------[0m
[1mShortest path from root project to androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime) for jvmCompileClasspath:[0m
:
\--- androidx.compose.runtime:runtime:1.11.4
[1mShortest path from root project to androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime) for jvmRuntimeClasspath:[0m
:
\--- androidx.compose.runtime:runtime:1.11.4
[1mShortest path from root project to androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime) for jvmTestCompileClasspath:[0m
:
\--- androidx.compose.runtime:runtime:1.11.4
[1mShortest path from root project to androidx.compose.runtime:runtime:1.11.4 (libs.androidx.compose.runtime) for jvmTestRuntimeClasspath:[0m
:
\--- androidx.compose.runtime:runtime:1.11.4
[1mSource: jvmMain
---------------[0m
(no usages)
[1mSource: jvmTest
---------------[0m
(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
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