https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

Gabriel Feo

03/04/2021, 12:14 AM
Is it possible in any way to use a compiler plugin with only one of the multiplatform targets? (does that even make sense?) My use case is Anvil, which only support JVM or Android projects for now
j

Javier

03/04/2021, 1:12 AM
I think it should work, the same question were asked in #squarelibraries a few days ago. BTW, why you don't use any Multiplatform DI framework? Kodein, Koin, PopKorn...
g

Gabriel Feo

03/04/2021, 1:23 AM
Thanks, didn’t know that channel! I’m getting an error here saying only JVM or Android projects are supported, even though those are my only targets. I prefer Dagger for compile-time safety, and my project is JVM and Android only
r

rnett

03/04/2021, 3:01 AM
I didn't see an answer (well, other than "it doesn't work") and am curious about this as well, from a compiler plugin standpoint. Plugins can detect the platform and disable themselves if it's not supported (either in the plugin itself or the gradle plugin), but I don't know of a way to specify it user side. There definitely should be one though. Someone (I will of no one else) should make an issue requesting it if no solution comes up. The best workaround is probably to make your own gradle plugin (using
KotlinCompilerPluginSupportPlugin
) and set
isApplicable
properly. You could also experiment with including the plugin jar manually, although I'm not sure if you can set different compiler args per target.
Reposting this in #compiler, too
4 Views