Skip to content

Tasks :classpathIndexCleanup and :compileTestKotlin don't have a declared dependency causing build to fail #1515

Closed
@ChristianIvicevic

Description

@ChristianIvicevic

What happened?

After scaffolding a new plugin using the template I realized that occasionally the (re)buliding the project would fail with the attached error message. Manually adding the following to my build.gradle.kts seems to resolve the issue.

tasks {
  withType<ClasspathIndexCleanupTask> {
    dependsOn(compileTestKotlin)
  }
}

Relevant log output or stack trace

21:44:10: Executing ':classes :testClasses'...

Reusing configuration cache.
> Task :initializeIntelliJPlugin SKIPPED
> Task :processTestResources NO-SOURCE
> Task :checkKotlinGradlePluginConfigurationErrors
> Task :generateLexer UP-TO-DATE
> Task :patchPluginXml UP-TO-DATE
> Task :generateParser UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :verifyPluginConfiguration
> Task :compileKotlin UP-TO-DATE
> Task :compileJava
> Task :classes
> Task :instrumentCode UP-TO-DATE
> Task :classpathIndexCleanup FAILED
> Task :compileTestKotlin FAILED
11 actionable tasks: 5 executed, 6 up-to-date
Configuration cache entry reused.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':classpathIndexCleanup' (type 'ClasspathIndexCleanupTask').
  - Gradle detected a problem with the following location: '/Users/christian.ivicevic/Code/Personal/intellij-clips/build/classes/kotlin/test/classpath.index'.
    
    Reason: Task ':classpathIndexCleanup' uses this output of task ':compileTestKotlin' 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 ':compileTestKotlin' as an input of ':classpathIndexCleanup'.
      2. Declare an explicit dependency on ':compileTestKotlin' from ':classpathIndexCleanup' using Task#dependsOn.
      3. Declare an explicit dependency on ':compileTestKotlin' from ':classpathIndexCleanup' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.5/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':compileTestKotlin' (type 'KotlinCompile').
  - Gradle detected a problem with the following location: '/Users/christian.ivicevic/Code/Personal/intellij-clips/build/classes/kotlin/test'.
    
    Reason: Task ':classpathIndexCleanup' uses this output of task ':compileTestKotlin' 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 ':compileTestKotlin' as an input of ':classpathIndexCleanup'.
      2. Declare an explicit dependency on ':compileTestKotlin' from ':classpathIndexCleanup' using Task#dependsOn.
      3. Declare an explicit dependency on ':compileTestKotlin' from ':classpathIndexCleanup' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.5/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

BUILD FAILED in 747ms
21:44:11: Execution finished ':classes :testClasses'.

Steps to reproduce

Using the template with the following gradle.properties I can trigger the error by invoking a (re)build from IntelliJ.

pluginSinceBuild=233
pluginUntilBuild=241.*
platformType=IC
platformVersion=2023.3.2
platformPlugins=
gradleVersion=8.5
kotlin.stdlib.default.dependency=false
org.gradle.configuration-cache=true
org.gradle.caching=true
systemProp.org.gradle.unsafe.kotlin.assignment=true

I am running this with our Nightly of 2024.1 in case it matters.

Gradle IntelliJ Plugin version

1.16.1

Gradle version

8.5

Operating System

macOS

Link to build, i.e. failing GitHub Action job

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions