sorry, basic questions im having trouble finding an answer to:
• kotlinx serialization plugin is inserting an annotation processor to generate code for classes annotated with
@kotlinx..Serializable
correct?
• the only (?) supported way to invoke this code is with the gradle/maven plugins? theres no argument i can give
kotlinc
that will invoke the appropriate annotation preprocessors?
• is there a guide that explains "so you want to add a field to an
@Serializable
class..."? How does kotlinx serialization do when I have old data and a new schema? If i use protobuf, can I get my hands on the untyped protobuf message primatives and write a migration script myself? Or similar for JSON?
j
jw
08/08/2024, 10:21 PM
It's a compiler plugin, not an annotation processor
jw
08/08/2024, 10:22 PM
You should be able to invoke it from kotlinc so long as it's on the plugin path. I don't know if it requires any arguments or not, but it'll tell you
e
ephemient
08/09/2024, 3:57 AM
Json throws on unknown fields by default but there's an option to ignore them. I haven't used the protobuf format but I expect it has that too.
ephemient
08/09/2024, 3:57 AM
if fields are missing, then they need defaults
ephemient
08/09/2024, 3:58 AM
with Json there are ways to have custom serializers operate on the JsonObject directly, not sure about Protobuf
ephemient
08/09/2024, 3:59 AM
I think you can pass a full plugin path to kotlinc? not sure, never did it before. just use Gradle
j
jw
08/09/2024, 4:01 AM
I'm pretty sure I've done serialization through the CLI, but it was like three plus years ago at least.