https://kotlinlang.org logo
#compiler
Title
# compiler
n

natario1

07/16/2022, 7:51 PM
Stupid question - I’m trying to write a hello world compiler plugin and apparently it is not being invoked. How would you go to debug this situation? I can see that the provider lambda returned by
KotlinCompilerPluginSupportPlugin.applyToCompilation
is invoked, so kotlin is preparing the args to be passed to the plugin. There I have a command line processor and an IrGenerationExtension. I’m adding all kinds of logs - println(), error(“Hello world”), send stuff to createDiagnosticReporter(). But I get nothing, compilation succeeds. Not sure what to do, maybe there is some compiler flag that can give me more information?
y

Youssef Shoaib [MOD]

07/16/2022, 9:27 PM
Ensure that the plugin ID you're passing is consistent. You can also use something like kotlin-compile-testing to see if your plugin would work normally not through Gradle. If it doesn't work in kotlin-compile-testing, then something is wrong with your ComponentRegistrar, but if it works, then check your gradle plugin.
n

natario1

07/17/2022, 10:17 AM
Thanks Youssef! I finally solved it. It would be very useful to have an option in gradle that prints the actual kotlinc invocation. I could not find it. (what went wrong if you’re curious - I was testing with a native target, and if you have kotlin.native.useEmbeddableCompilerJar=true (default from 1.7), you don’t need to override getPluginArtifactForNative(). I was on 1.7, but I discovered that a third party gradle plugin, added the old way (buildscript block, classpath configuration) was actually downgrading the version to 1.6.21)
3 Views