JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
14.85k stars 1.08k forks source link

Gradle tasks are using outputs without declaring an explicit or implicit dependency #4739

Closed romainbsl closed 1 week ago

romainbsl commented 2 weeks ago

Describe the bug

Migrating from Kotlin 1.9.2x and Compose 1.6.0-alpha01 👉 Kotlin 2.0.0-RC2 + Compose Compiler + Compose Multiplatrform 1.6.10-beta03 and running ./gradlew check I get multiple errors about tasks that are using outputs from generateResourceAccessorsForAndroidUnitTest without declaring explicit dependency.

Example:

Reason: Task ':framework:compose:kodein-di-framework-compose:generateDebugLintReportModel' uses this output of task ':framework:compose:kodein-di-framework-compose:generateResourceAccessorsForAndroidUnitTest' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

Using the following workaround helps remove warnings:

tasks.withType<LintModelWriterTask> {
    dependsOn("generateResourceAccessorsForAndroidUnitTest")
}
tasks.withType<LintModelMetadataTask> {
    dependsOn("generateResourceAccessorsForAndroidUnitTest")
}
tasks.withType<AndroidLintAnalysisTask> {
    dependsOn("generateResourceAccessorsForAndroidUnitTest")
}

Affected platforms

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Go to Kodein's repo and clone kotlin-2 branch
  2. Comment lines from 28 to 33 include
  3. Run gradle task check
  4. See Gradle warning/error

Expected behavior

Not having to use workaround.

igordmn commented 2 weeks ago

Reproduced with these steps:

  1. Go to Kodein's repo and clone kotlin-2 branch
  2. Comment lines from 28 to 33 include
  3. ./gradlew framework:compose:kodein-di-framework-compose:check
  4. See Gradle warning/error

After commenting the Compose plugin, it is successful:

plugins {
    kodein.library.mppWithAndroid
    alias(libs.plugins.compose.compiler)
    //alias(libs.plugins.compose)
}

kotlin.kodein {
    jsEnv()
    allComposeUi()

    common.mainDependencies {
        implementation("org.jetbrains.compose.runtime:runtime:1.6.10-beta03")
        api(projects.kodeinDi)
    }

    android {
        sources.mainDependencies {
            api(projects.framework.android.kodeinDiFrameworkAndroidX)
            implementation(libs.android.x.lifecycle.viewmodel.compose)
        }
    }
}
terrakok commented 1 week ago

Google issue: https://issuetracker.google.com/issues/333831734