From 718907eb9b5252e44d704609f63fe280765ba776 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Fri, 5 Oct 2018 14:43:37 +0200 Subject: Example how to make case class serializable (#450) * Example how to make case class serializable * Fixed typo in docs --- docs/pages/4 - Tasks.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'docs/pages/4 - Tasks.md') diff --git a/docs/pages/4 - Tasks.md b/docs/pages/4 - Tasks.md index a08bd032..6c7737e0 100644 --- a/docs/pages/4 - Tasks.md +++ b/docs/pages/4 - Tasks.md @@ -92,6 +92,16 @@ automatically JSON-serialized and stored at `out/classFiles/meta.json`. The return-value of targets has to be JSON-serializable via [uPickle](https://github.com/lihaoyi/upickle). +In case you want return your own +case class (e.g. `MyCaseClass`), you can make it JSON-serializable by adding the +following implicit def to its companion object: + +```scala +object MyCaseClass { + implicit def rw: upickle.default.ReadWriter[MyCaseClass] = upickle.default.macroRW +} +``` + If you want to return a file or a set of files as the result of a `Target`, write them to disk within your `T.ctx().dest` available through the [Task Context API](#task-context-api) and return a `PathRef` to the files you -- cgit v1.2.3