https://kotlinlang.org logo
h

Henrik Johansson

01/26/2021, 2:39 PM
Do I have to create serializers for Java types? For example UUID and Instant or is there some library available for it?
s

stephanmg

01/26/2021, 2:42 PM
h

Henrik Johansson

01/26/2021, 2:53 PM
I have it working for standard Kotlin types but I get
Serializer has not been found for type 'UUID'
for example
I have read (knock, knock) those links but they are voluminous to say the least and I am in Maven land which seems a bit like second hand 🙂
m

Matteo Mirk

01/26/2021, 2:55 PM
I see, so you need to write a custom serializer for it, which probably just uses its toString(): https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serializers.md#custom-serializers
h

Henrik Johansson

01/26/2021, 2:56 PM
Ah I was hoping that the standard JVM typs had serializers somewhere
m

Matteo Mirk

01/26/2021, 2:56 PM
in the principal README there are instructions on how to configure kotlinx.serialization in a pom, so no one excludes Maven 😉
If the type you need hasn’t an explicit
.serializer()
function (generated by the compiler) then you either need to annotate the class (you own it) or you need to write a custom one. UUID seems the latter case
h

Henrik Johansson

01/26/2021, 3:00 PM
Thanks! Ill get to writing serializers now 🙂
👍 2
s

stephanmg

01/26/2021, 3:01 PM
@Matteo Mirk how would we forget mvn anyway
m

Matteo Mirk

01/26/2021, 3:05 PM
surely not, maven is still strong, but I can understand Henrik because Gradle is preferred in Kotlin world, many docs only mention Gradle configurations and MPP only works with it
👍 2
s

stephanmg

01/26/2021, 3:06 PM
yeah, I think people like Gradle a lot these days, not only in the Kotlin community
m

Matteo Mirk

01/26/2021, 3:08 PM
personally I haven’t still got into it, but every config seems very chaotic to me because it’s code and so there are 1000 ways of writing it. As of now I still prefer Maven, even with its limitations.
s

stephanmg

01/26/2021, 3:12 PM
Yeah I agree, I am undecided, but well, I’ll stick to what the team prefers, both tools work of course
I’ve the impression Gradle can get sometimes quiet complex for me (really TMTOWTDIs)
m

Matteo Mirk

01/26/2021, 3:13 PM
The best evolution for Maven would be Polyglot Maven, but sadly it’s little known 😕
s

stephanmg

01/26/2021, 3:16 PM
phew!
that’s interesting
m

Matteo Mirk

01/26/2021, 3:18 PM
yeah it is! The best part to me is that you can use Yaml and get rid of XML, or you can use one of the supported languages to reproduce the pom configuration AND use code where it’s needed without resorting to maven plugins
s

stephanmg

01/26/2021, 3:21 PM
well I will consider this eventually when I have the lead
👍 1
😄
3 Views