David Herman
03/08/2024, 8:01 PMDavid Herman
03/08/2024, 8:02 PMval kspConfig = KSPJvmConfig.Builder().apply {
// All configurations happen here.
}.build()
val exitCode = KotlinSymbolProcessing(kspConfig, listOfProcessors, kspLoggerImpl).execute()
☝️ from the post. Where does this code even go? What does my build.gradle.kts file look like? What does migrating from KSP to KSP2 look like?Ting-Yuan Huang
03/09/2024, 3:14 AMksp.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.David Herman
03/09/2024, 3:15 AMTing-Yuan Huang
03/09/2024, 3:17 AMDavid Herman
03/09/2024, 3:17 AM