I did some googling around and I can't find exampl...
# ksp
w
I did some googling around and I can't find examples of this scenario. I've got a custom gradle plugin I use for some projects and I'd like to write and invoke a ksp processor from it. Like in the apply function of a gradle plugin, is it possible to explicitly setup the symbol processor environment and invoke my ksp processor? Does anyone have any examples?
1
j
in the target project: • apply the ksp plugin from
pluginManager.apply
• look up the ksp configuration from
configurations.getByName
• add your ksp processor dependency with
Configuration.add
on the value returned from above
w
For the life of me, I cannot figure out how explicitly add the ksp dependency to the dependencySet on the configuration. Here is what I'm doing, but it keeps complaining that "path" is missing. what am I missing?
Copy code
project.pluginManager.apply(KspGradleSubplugin::class.java)
val config = project.configurations.getByName("ksp")
val path = mutableMapOf("path" to ":kspprocessor")
config.dependencies.add(project.dependencies.project(path))
Copy code
org.gradle.api.InvalidUserDataException: Required keys [path] are missing from map {}.
j
Maybe try
project.dependencies.add("ksp", project.dependencies.project(mapOf("path" to ":kspprocessor")))
I'm not at a computer to look, but I've definitely done both forms and had it work
w
No urgency, getting late for me anyway. That second notation worked and I ran into one more issue. The project dependency path is looking in the project that is applying my plugin and not the project that my plugin is a part of. I fixed that by moving the processor to it's own composite build and added a dependency with project.dependencies.create and normal dependency notation. the import appears to work fine now, but the processor is not being called. Do I need to do something special to the created dependency like how you normally use the function "ksp("<dependency notation>") in a dependency handler block?
I'm looking in all the wrong places -_-. Might have had something to do with this message:
> Task :binding-check:kspKotlin NO-SOURCE
. Didn't realize ksp doesn't run if you have no kotlin sources in your test project. Applied it to a real project and the process ran without issue. Thanks for your assistance sir
👍 1