Macros that generate com.esotericsoftware.kryo.Serializer implementations in compile time, based on compile time reflection.
Add the following resolver
resolvers += Resolver.bintrayRepo("evolutiongaming", "maven")
Add the library to your dependencies list
libraryDependencies += "com.evolutiongaming" %% "kryo-macros" % "1.0.0"
Generate some serializers for your case classes
import com.evolutiongaming.kryo.Serializer
case class Player(name: String)
val serializer = Serializer.make[Player]
That's it! You have generated a com.esotericsoftware.kryo.Serializer implementation for your Player. You must know what to do with it if you are here :)
Just add the following line to your sbt build file
scalaOptions += "-Xmacro-settings:print-serializers"
- Only case classes supported
- No mutable Map's as class fields supported
For more examples, please, check out SerializerMacroSpec