rrva
03/26/2023, 3:54 PM@OptIn(ExperimentalCompilerApi::class)
@AutoService(CompilerPluginRegistrar::class)
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)
messageCollector.report(
CompilerMessageSeverity.WARNING,
"*** Hello from MyPlugin ***"
)
}
}
in the project which uses the plugin, I have defined
tasks.withType<KotlinCompile> {
kotlin {
jvmToolchain(19)
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:
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
Elizabeth Thomas
04/25/2023, 4:43 PMrrva
04/26/2023, 12:13 PMimplementation("com.google.auto.service:auto-service:1.0.1")
kapt("com.google.auto.service:auto-service:1.0.1")
as well as the kapt plugin in the plugins section
kotlin("kapt") version("1.8.20")