diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-15 14:03:38 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-15 14:03:38 -0800 |
commit | 28c099486199c8fbf1c1f5247278a0484e8a747b (patch) | |
tree | 9de10743b6cbecf32cffae78fa77ed5646e7ff8c /core/src/main/scala/mill/eval/Evaluator.scala | |
parent | 51a433c8acff390a0109d92de222c9f8361b0bcf (diff) | |
download | mill-28c099486199c8fbf1c1f5247278a0484e8a747b.tar.gz mill-28c099486199c8fbf1c1f5247278a0484e8a747b.tar.bz2 mill-28c099486199c8fbf1c1f5247278a0484e8a747b.zip |
Strip out `play-json` dependency in favor of `upickle`, which we are forced to use anyway due to Ammonite. Saves us from classloading play-json and Jackson, shaving off a few hundred ms from the cold no-op runtime
Diffstat (limited to 'core/src/main/scala/mill/eval/Evaluator.scala')
-rw-r--r-- | core/src/main/scala/mill/eval/Evaluator.scala | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/core/src/main/scala/mill/eval/Evaluator.scala b/core/src/main/scala/mill/eval/Evaluator.scala index 6e103ace..74cb77d3 100644 --- a/core/src/main/scala/mill/eval/Evaluator.scala +++ b/core/src/main/scala/mill/eval/Evaluator.scala @@ -4,7 +4,7 @@ import ammonite.ops._ import mill.define.Task import mill.discover.Labelled import mill.util.{Args, MultiBiMap, OSet} -import play.api.libs.json.{Format, JsValue, Json} + import scala.collection.mutable class Evaluator(workspacePath: Path, @@ -61,15 +61,15 @@ class Evaluator(workspacePath: Path, val cached = for{ metadataPath <- metadataPath - json <- scala.util.Try(Json.parse(read.getInputStream(metadataPath))).toOption - (cachedHash, terminalResult) <- Json.fromJson[(Int, JsValue)](json).asOpt + json <- scala.util.Try(upickle.json.read(read(metadataPath))).toOption + (cachedHash, terminalResult) <- scala.util.Try(upickle.default.readJs[(Int, upickle.Js.Value)](json)).toOption if cachedHash == inputsHash } yield terminalResult cached match{ case Some(terminalResult) => val newResults = mutable.LinkedHashMap.empty[Task[_], Any] - newResults(terminal) = labeling(terminal).format.reads(terminalResult).get + newResults(terminal) = labeling(terminal).format.read(terminalResult) (newResults, Nil) case _ => @@ -83,9 +83,7 @@ class Evaluator(workspacePath: Path, metadataPath.foreach( write.over( _, - Json.prettyPrint( - Json.toJson(inputsHash -> terminalResult) - ), + upickle.default.write(inputsHash -> terminalResult, indent = 4) ) ) @@ -99,7 +97,7 @@ class Evaluator(workspacePath: Path, targetDestPath: Option[Path]) = { targetDestPath.foreach(rm) - var terminalResult: JsValue = null + var terminalResult: upickle.Js.Value = null val newEvaluated = mutable.Buffer.empty[Task[_]] val newResults = mutable.LinkedHashMap.empty[Task[_], Any] for (target <- group.items if !results.contains(target)) { @@ -114,8 +112,8 @@ class Evaluator(workspacePath: Path, for(targetLabel <- labeling.get(target)){ terminalResult = targetLabel .format - .asInstanceOf[Format[Any]] - .writes(res.asInstanceOf[Any]) + .asInstanceOf[upickle.default.ReadWriter[Any]] + .write(res.asInstanceOf[Any]) } newResults(target) = res } |