I was playing around with Anvil, and I got a quest...
# squarelibraries
s
I was playing around with Anvil, and I got a question. I got one module which is configured with the
org.jetbrains.kotlin.multiplatform
plugin, and I’d like to have the android target specifically have one class which is annotated with
ContributesBinding
. Thing is, I can’t quite apply the
com.squareup.anvil
plugin on that module since it’s MP and it seems to break everything if I do that. Is there a way I can only apply the plugin to my android target, or is there something completely different that I should do instead? Maybe some sample which does this that you’re aware of which I can take a look at?
e
Looked at the source of the anvil gradle plugin, there is nothing in there that would not work if you applied the relevant android gradle plugin also 🙂. For the automatically added runtime (that contains the anvil annotations), its a simple dependency so you can always add
com.squareup.anvil:annotations:<anvilVersion>
directly to the dependencies of the android source set (although I think anvil adds this for you automatically)
Might be able to help better with more information
s
Aha, apply the anvil and the android library plugin, interesting idea. What I was playing around with yesterday was simply creating another module, which imports the multiplatform module and it itself is the one which applies the anvil plugin and the android library plugin and so on and it did seem to work I think. But yeah your idea sounds interesting as well, might try that too if my approach ends up bringing me any troubles or I need to use expect/actual which would force me to be inside the same module. Thanks a lot!