Skip to content

buildHealth suggests moving some commonMain dependencies to jvmMain #1784

Description

@veyndan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions