Hello team! I'm trying to create a compiler plugin...
# compiler
g
Hello team! I'm trying to create a compiler plugin, but I'm stuck. I see that the plugin is working with
compileKotlinJvm
task, but not with
compileKotlinJs
I'm not sure that I'm adding the plugin to the compile tasks in the correct way as well
Copy code
tasks.withType<AbstractKotlinCompile<*>> {
    dependsOn(compilerPluginConfiguration)
    compilerOptions.freeCompilerArgs.add(provider { "-Xplugin=${compilerPluginConfiguration.files.first()}" })
}
I created a separate configuration
compilerPluginConfiguration
and trying to pull the plugin jar from it. I chose this naive approach to simplify the prototype, but it seems like a bad idea now. Any suggestion on how to apply a compiler plugin in the correct way?
b
If you want to go the manual route, and your plugin doesn't require any arguments, there's a Gradle configuration available for compiler plugins:
kotlinCompilerPluginClasspath
. Otherwise the recommendation would be to create a Gradle plugin from which you can also specify any input you need for your plugin in an idiomatic way.
g
Oh, that's great! It is working on js configuration as well!
🚀 1