Hi, I followed this <article> for a compiler plugi...
# compiler
j
Hi, I followed this article for a compiler plugin. I see the kotlin subplugin artifact get pulled but I don’t see it getting applied to the compile toolchain, IE my commandlineprocessor never gets invoked. I matched the IDs and args but I don’t see it working. The article uses AutoService to wire dependencies but it doesn’t go into detail and i’m worried the plugin isn’t being found. Is there a way to let the kotlin compiler know about the processor or CompilerPluginRegistrar?
j
ok i’ll create that file and try it out. thanks!
@Rick Clephas Unfortunately that didn’t seem to work. Nothing was logged or crashed (I threw an error to check). This is in an Android Jetpack Compose Context if that makes a difference
r
Could you possibly share some of the gradle and kotlin plugin code? Otherwise feel free to checkout KMP-NativeCoroutines, it has a Kotlin compiler and Gradle plugin (and some other stuff, but that isn’t that relevant for this issue).
j
gradle plugin build.gradle.kt
gradle plugin.cpp
kotlin plugin build.gradle.kt
command line processor
using kotlin 1.8.22
r
So it seems you are not actually forwarding any options to your compiler plugin. In that case it might be expected that the commandlineprocessor isn't invoked (not 100% sure). Why do you want it to be invoked if there aren't any options?
j
I just want it to run. I tried with arguments before but it didn’t make a difference. I can try putting back but this is just an “apply” or “dont apply” situation, no configuration
r
Alright in that case I wouldn't worry about the CommandLineProcessor. I guess you also have a CompilerPluginRegistrar, right? Do you have a META-INF file for that one as well? https://github.com/rickclephas/KMP-NativeCoroutines/blob/7f2c99fb4a93dcd5327fafd577aa3cd7fff47a30/kmp-nativecoroutines-compiler/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
j
yes, I have both.
and they are in the jar
i double checked for typos. i’ll drop the commandline processor and see where I get.
r
Hmm alright, in that case I am a little out of ideas. But like I said maybe if you compare the code to KMP-NativeCoroutines you might be able to see the difference.
j
ya, i am comparing against that and ksp and some other plugins, not sure what i am doing wrong
¯\_(ツ)_/¯
thanks for your help!
👍 1
@Rick Clephas FYI I am not seeing the sub plugin get pulled at all anymore, so whatever mechanism that is does not seem to work. The Gradle plugin gets invoked but it never gets wired up to the kotlin compiler to ask for the sub plugin.
r
How are you testing this exactly?
j
running gradle task build
they are being added to the Android Compose app via an
includedBuild
option
r
In that case make sure to do a clean build, to prevent any caches from interfering. Note: includedBuilds aren't officially supported. However in my experience they work oke.
j
ya i have been destroying everything I can find, including
~/.gradle/caches
And I am making changes to the gradle plugin and seeing the updates. its just not pulling the kotlin plugin. i know there is new caches for kotlin but i am not sure where to delete those from