Is it possible to apply the KotlinX.Serialization ...
# serialization
c
Is it possible to apply the KotlinX.Serialization plugin only to test sources (
commonTest
,
jvmTest
…)?
s
No. However, without any
@Serializable
annotations, plugin will not perform code transformations. You can try to add runtime dependency to test sources only. It is not recommended, but will probably work.
c
For context, it's a library that doesn't use KotlinX.Serialization directly, but through the strategy pattern it may be asked to serialize elements indirectly. I'd like to create
@Serializable
classes in the library's test sources, without the exported files having any dependency on KxS.
r
You could also try defining your serializable classes in a separate module where you apply the plugin, then depend on that module from your test sources
c
There are only ~5 of these classes so that sounds overkill, but it is conceptually simple so I may end up with that