diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-04 23:26:45 -0700 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-04 23:26:45 -0700 |
commit | cc4596f415c63bb9e03e07f714b6ce29e9cfe533 (patch) | |
tree | db7357caf89a18fd5f5e6b822c51b25cd3dd70bc /core/src | |
parent | 7cd2b7ef3d367a5638cf6ae1fdc62f0bee466f8e (diff) | |
download | mill-cc4596f415c63bb9e03e07f714b6ce29e9cfe533.tar.gz mill-cc4596f415c63bb9e03e07f714b6ce29e9cfe533.tar.bz2 mill-cc4596f415c63bb9e03e07f714b6ce29e9cfe533.zip |
Get rid of custom `coursier.Dependency` formatter, which was only needed due to initialization order problems, which we can solve by making everything `lazy val`s
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/scala/forge/package.scala | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/core/src/main/scala/forge/package.scala b/core/src/main/scala/forge/package.scala index f183cddb..31a79b6a 100644 --- a/core/src/main/scala/forge/package.scala +++ b/core/src/main/scala/forge/package.scala @@ -73,37 +73,8 @@ package object forge { } } - implicit val crFormat: Format[ammonite.ops.CommandResult] = Json.format - implicit val modFormat: Format[coursier.Module] = Json.format - // https://github.com/playframework/play-json/issues/120 - // implicit val depFormat: Format[coursier.Dependency] = Json.format - implicit val depFormat: Format[coursier.Dependency] = new Format[coursier.Dependency] { - def writes(o: Dependency) = { - Json.obj( - "module" -> Json.toJson(o.module), - "version" -> Json.toJson(o.version), - "configuration" -> Json.toJson(o.configuration), - "exclusions" -> Json.toJson(o.exclusions), - "attributes" -> Json.toJson(o.attributes), - "optional" -> Json.toJson(o.optional), - "transitive" -> Json.toJson(o.transitive) - ) - } - - def reads(json: JsValue) = json match{ - case x: JsObject => - JsSuccess(coursier.Dependency( - Json.fromJson[coursier.Module](x.value("module")).get, - Json.fromJson[String](x.value("version")).get, - Json.fromJson[String](x.value("configuration")).get, - Json.fromJson[coursier.Attributes](x.value("attributes")).get, - Json.fromJson[Set[(String, String)]](x.value("exclusions")).get, - Json.fromJson[Boolean](x.value("optional")).get, - Json.fromJson[Boolean](x.value("transitive")).get - )) - - case _ => JsError("Dep must be an object") - } - } - implicit val attrFormat: Format[coursier.Attributes] = Json.format + implicit lazy val crFormat: Format[ammonite.ops.CommandResult] = Json.format + implicit lazy val modFormat: Format[coursier.Module] = Json.format + implicit lazy val depFormat: Format[coursier.Dependency]= Json.format + implicit lazy val attrFormat: Format[coursier.Attributes] = Json.format } |