If you're using KSP's Gradle plugin, just set the Gradle property
ksp.useKSP2
to true and use it as if it was KSP1.
To use KSP2 without KSP's Gradle plugin, e.g., without the
ksp(some_processor)
dependencies, you'll only need
implementation("com.google.devtools.ksp:symbol-processing-aa-embeddabe:<version>")
in
build.gradle.kts
. The
val kspConfig...
snippet is placed in your main or test entry points. For example, you'll need to setup
sourceRoots
and
javaSourceRoots
to tell KSP where to find the source files, and
kotlinOutputDir
to write generated Kotlin files. Here are a few examples that fill up the config and calls KSP:
1.
KSP's test code
2. KSP's
Gradle plugin. This one creates a clean classpath and is a bit complicated.