summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-10-31 21:32:50 -0700
committerLi Haoyi <haoyi.sg@gmail.com>2017-10-31 21:32:50 -0700
commit9acfd75aa69be861a904b9b48b373584e67b4def (patch)
treef790194598767cb3c34cff441d1e38d20256f570 /src/main
parent2482a37652e9e50759b6357e3f078616c6365941 (diff)
downloadmill-9acfd75aa69be861a904b9b48b373584e67b4def.tar.gz
mill-9acfd75aa69be861a904b9b48b373584e67b4def.tar.bz2
mill-9acfd75aa69be861a904b9b48b373584e67b4def.zip
Trying to evaluate more of `MetacircularTests` no longer crashes, though `compiled` still does...
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/forge/package.scala32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/main/scala/forge/package.scala b/src/main/scala/forge/package.scala
index 621f2345..00562a85 100644
--- a/src/main/scala/forge/package.scala
+++ b/src/main/scala/forge/package.scala
@@ -1,5 +1,6 @@
import play.api.libs.json._
import ammonite.ops.{Bytes, Path}
+import coursier.Dependency
import forge.util.Args
package object forge {
@@ -56,6 +57,35 @@ package object forge {
implicit val crFormat: Format[ammonite.ops.CommandResult] = Json.format
implicit val modFormat: Format[coursier.Module] = Json.format
- implicit val depFormat: Format[coursier.Dependency] = 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
}