Search code examples
springspring-bootkotlingradlegradle-plugin

How can I configuration spring-boot-configuration-processor when I would like to change from KAPT to KSP? I get every time error


Basic problem, kapt is in maintenance mode. So I would like to change to ksp. In theory, it's the equivalent of faster like kapt. The changing option is not clear.

I did:

This was

plugin {
   ...
   kotlin("kapt") version "1.7.20"
   ...

replaced by

plugin {
   ...
   id("com.google.devtools.ksp") version "1.7.20-1.0.7"
   ...
}

and there were

annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
kapt("org.springframework.boot:spring-boot-configuration-processor")

replaced by

annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
ksp("org.springframework.boot:spring-boot-configuration-processor")

So, when I build project I got below error:

> Task :kspKotlin FAILED
e: [ksp] No providers found in processor classpath.
e: Error occurred in KSP, check log for detail

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':kspKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* 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 829ms
1 actionable task: 1 executed

I've been mining the internet for almost two days, but I still haven't found a solution to this problem. If anyone knows, I will be very happy! :)


Solution

  • KSP is not a direct replacement to kapt. Changing one name to another won't do the trick.

    spring-boot-configuration-processor wasn't built to work with KSP, so this line

    ksp("org.springframework.boot:spring-boot-configuration-processor")
    

    won't do anything.