kotlinx-kover icon indicating copy to clipboard operation
kotlinx-kover copied to clipboard

Missing task dependency for koverCachedVerify when Java sources are present

Open obecker opened this issue 9 months ago • 0 comments

Describe the bug I'm using the kover plugin with the following configuration:

kover {
    reports {
        total {
            html {
                onCheck = true
            }
        }
    }
}

The project has Kotlin sources as well as generated Java sources.

When running the build task without the test task, gradle terminates with an error message.

Errors Running gradle build -x test produces

* What went wrong:
A problem was found with the configuration of task ':example:koverCachedVerify' (type 'KoverDoVerifyTask').
  - Gradle detected a problem with the following location: '/xxx/example/build/generated'.

    Reason: Task ':example:koverCachedVerify' uses this output of task ':example:compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':example:compileTestJava' as an input of ':example:koverCachedVerify'.
      2. Declare an explicit dependency on ':example:compileTestJava' from ':example:koverCachedVerify' using Task#dependsOn.
      3. Declare an explicit dependency on ':example:compileTestJava' from ':example:koverCachedVerify' using Task#mustRunAfter.

    For more information, please refer to https://docs.gradle.org/8.12.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

Expected behavior The task is executed without errors.

I can solve this by myself by adding

afterEvaluate {
    tasks["koverGenerateArtifactJvm"].dependsOn("compileTestJava")
}

but it would be great of the plugin could take care of that.

Environment

  • Kover Gradle Plugin version: [e.g. 0.9.1]
  • Gradle version: [e.g. 8.12.1]
  • Kotlin project type: Kotlin/JVM

obecker avatar Feb 26 '25 12:02 obecker