Closed ValdZX closed 3 years ago
Hi @ValdZX, thanks for the contribution, unfortunately I can't accept it in it's current form, as I don't want to add a dependency to the base bignum library except for the stdlib, and potentialy coroutines at some point. This was discussed a bit in #170 . If I am not mistaken it would be possible to publish a separate bignum-serialization library that could solve the issue the way you did, do you think that would work? If it could I'd prefer to go that way.
This solution is inspired by kotlinx-datetime In the common from new dependencies only plugin serialization and serializationJson for tests. I have no idea how it realize in separate module witout annotation @Serializable on class BigDecimal
Ok, let me give this a bit more thought over weekend, and decide on way forward.
I'll work on setting up a separate library that will just contain the KSerializer for BigInteger/Decimal and provide a serialization module, then when the users will be able to use it by importing the library and adding the serialization module when they are creating their instance of kotlinx serialization json. It's wont be as easy for users as having @Serializable
on the classes themselves but it doesn't force a dependency on the people not using it, and also allows us to target the platforms we want and not only the ones kotlinx serialization supports (this is not a problem at the moment, but I've been burned by this before)
If you want me to include you commits, could you fix that problem that CLA_bot is complaining about, you might need to set up the email in you git client to the one you are using on github and then amend the commits and force push.
Gradle has function compileOnly for add dependecy without adding library to archive. It make support kotlinx serialization optional
Gradle has function compileOnly for add dependecy without adding library to archive. It make support kotlinx serialization optional
I'm not a gradle expert but I am not sure that is the proper way to go, look at this forum post for more details https://discuss.gradle.org/t/is-it-recommended-to-use-compileonly-over-implementation-if-another-module-use-implementation-already/26699/2. Additionally I'm not sure how compileOnly would work with somebody including different version of kotlinx in their project. And it still keeps the problem of being able to support only the targets that serialization supports, currently the set is same, but that might change (i.e. riscv32/64 gets support, then we would need to wait on serialization to support that before we could support it)
Hi @jQrgen,
here are some instructions https://github.com/ionspin/kotlin-multiplatform-bignum#serialization
All committers have signed the CLA.