Trying to write a small compiler plugin following ...
# compiler
Trying to write a small compiler plugin following How can I debug why the kotlin compiler plugin is not being activated? I can see that the gradle plugin part is being activated OK, and I can set a breakpoint in the debugger for it when running gradle in debug mode. But the kotlin compiler part (inheriting from CompilerPluginRegistrar) is not running, and not printing my test message as per this code:
Copy code
class MyPlugin : CompilerPluginRegistrar() {
    override val supportsK2: Boolean
        get() = true

    override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {

        val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
            "*** Hello from MyPlugin ***"
in the project which uses the plugin, I have defined
Copy code
tasks.withType<KotlinCompile> {
    kotlin {
        kotlinOptions {
            verbose = true
            useK2 = false
and when running
./gradlew --debug
i can grep for KOTLIN in the logs and see some of the compiler output, where my plugin is mentioned:
Copy code
2023-03-26T12:50:40.339+0200 [DEBUG] [org.gradle.api.Project] [KOTLIN] Subplugin my-plugin loaded
2023-03-26T12:50:40.339+0200 [DEBUG] [org.gradle.api.Project] [KOTLIN] Loading subplugin my-plugin
2023-03-26T12:50:40.339+0200 [DEBUG] [org.gradle.api.Project] [KOTLIN] Adding 'se.rrva:my-plugin:1.0.5' to 'kotlinCompilerPluginClasspathTest' configuration
annotation processing was not working for @AutoService, now it does and I got my printouts as expected
thanks for the article by the way @bnorm
@rrva what did you have to do to get the annotation processing working with @Autoservice?
in the dependencies section in gradle I had forgotten the annotation processor:
Copy code
as well as the kapt plugin in the plugins section
Copy code
kotlin("kapt") version("1.8.20")