Hi All, I am new to KSP and have implemented a co...
# ksp
m
Hi All, I am new to KSP and have implemented a couple of annotations that generate code for the classes they are annotated on. This works fine when I test on a module in the same project. However, when I deploy the annotations and use them as a dependency from a library jar file, the annotations and processor classes are accessible/usable, but the code generation does not occur. I would like to know if anything needs to go into the project build script to allow this generation to occur. I have tried using the KSP plugins and dependencies, but it still doesn’t work. My deployed library jar, when extracted, contains the classes under the package structure as expected. I.e., lib.jar: com.annotation.uti: [All the classes here]. I do see the following message when I build my annotated gradle project: e: [ksp] No providers found in processor classpath. Please tell me what I need to include, or are there any examples showing this working as a deployed library? #ksp
Figured it out. I will leave this here for those who may encounter the same issue. Your deployed library META-INF folder needs to also contain the services/com.google.devtools.ksp.processing.SymbolProcessorProvider directory and file. If you are building your library from a multi-module project, you can do the following in the gradle jar task.
Copy code
tasks {
    jar {
        //...
        from(project(":processor").layout.buildDirectory.dir("resources/main/META-INF").get()) {
            into("META-INF")
        }

        manifest {
            // ...
        }

        archiveFileName.set("${rootProject.name}-$version.${archiveExtension.get()}")
    }
}