ksp: Failed to upgrade to Kotlin 1.9

I updated my project to Kotlin 1.9.0 and Gradle 8.2, and got the following build info.

A problem was found with the configuration of task ':kaptGenerateStubsKotlin' (type 'KaptGenerateStubsTask').
  - Gradle detected a problem with the following location: 'D:\FreelanceProjects\sami\etip-backend\build\generated\ksp\main\kotlin'.

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

    Possible solutions:
      1. Declare task ':kspKotlin' as an input of ':kaptGenerateStubsKotlin'.
      2. Declare an explicit dependency on ':kspKotlin' from ':kaptGenerateStubsKotlin' using Task#dependsOn.

Add the following in the build.gradle.kts, did not resolve the issue.


tasks.named("kaptGenerateStubsKotlin"){
    dependsOn("kspKotlin")
}

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 8
  • Comments: 19 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I solved the issue.

The kapt plugin must be declared after the ksp plugin.

plugins {
kotlin("jvm") version "1.9.0"
-kotlin("kapt") version "1.9.0"
id("com.google.devtools.ksp") version "1.9.0-1.0.12"
+kotlin("kapt") version "1.9.0"
}

I got this warning in upgrading to kotlin 1.9.10

ksp-1.8.10-1.0.9 is too old for kotlin-1.9.10. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10.

is there any ksp version that is compatible with the kotlin 1.9.10

you can try KSP 1.9.10-1.0.13

I got this warning in upgrading to kotlin 1.9.10

ksp-1.8.10-1.0.9 is too old for kotlin-1.9.10. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10.

is there any ksp version that is compatible with the kotlin 1.9.10

I guess some of the issues come from a previous workaround which lets IDE be aware of generated source:

kotlin {
	sourceSets.main {
		kotlin.srcDir("build/generated/ksp/main/kotlin")
	}
}

KSP has been doing this automatically, with dependencies correctly set up since 1.0.9. If you have this workaround in your build script, please try to remove it and see if the problem remains.

@Enaium @uladzislau-hryshechka can you provide mode details on how your project is configured? From @hantsy 's case, it does seem like applying dataframe added a dependency since dataframe generates code with KSP that might be taken as input to KAPT.

https://github.com/babyfish-ct/jimmer/tree/main/example/kotlin/jimmer-sql-kt

kotlin("jvm") version "1.9.0"
kotlin("kapt") version "1.9.0"
kotlin("plugin.spring") version "1.9.0"
id("com.google.devtools.ksp") version "1.9.0-1.0.12"