mirror of https://github.com/sbt/sbt.git
Write JSON to file without String. #1763
This commit is contained in:
parent
0cad84b4bb
commit
40b65c914a
|
|
@ -39,24 +39,16 @@ object Tracked {
|
|||
}
|
||||
private[sbt] def lastOuputWithJson[I, O: Pickler: Unpickler](cacheFile: File)(f: (I, Option[O]) => O): I => O = in =>
|
||||
{
|
||||
val previous: Option[O] = fromJsonFile[O](cacheFile)
|
||||
val previous: Option[O] = try {
|
||||
fromJsonFile[O](cacheFile).toOption
|
||||
} catch {
|
||||
case e: Throwable => None
|
||||
}
|
||||
val next = f(in, previous)
|
||||
toJsonFile(next)(cacheFile)
|
||||
IO.createDirectory(cacheFile.getParentFile)
|
||||
toJsonFile(next, cacheFile)
|
||||
next
|
||||
}
|
||||
private[sbt] def fromJsonFile[A: Unpickler](file: File): Option[A] =
|
||||
try {
|
||||
val s = IO.read(file, IO.utf8)
|
||||
fromJsonString[A](s).toOption
|
||||
} catch {
|
||||
case e: Throwable => None
|
||||
}
|
||||
private[sbt] def toJsonFile[A: Pickler](a: A)(file: File): Unit =
|
||||
{
|
||||
val str = toJsonString(a)
|
||||
IO.write(file, str, IO.utf8)
|
||||
}
|
||||
|
||||
def inputChanged[I, O](cacheFile: File)(f: (Boolean, I) => O)(implicit ic: InputCache[I]): I => O = in =>
|
||||
{
|
||||
val help = new CacheHelp(ic)
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ private[sbt] object JsonUtil {
|
|||
def parseUpdateReport(md: ModuleDescriptor, path: File, cachedDescriptor: File, log: Logger): UpdateReport =
|
||||
{
|
||||
try {
|
||||
val s = IO.read(path, IO.utf8)
|
||||
val lite = fromJsonString[UpdateReportLite](s).get
|
||||
val lite = fromJsonFile[UpdateReportLite](path).get
|
||||
fromLite(lite, cachedDescriptor)
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
|
|
@ -21,8 +20,8 @@ private[sbt] object JsonUtil {
|
|||
}
|
||||
def writeUpdateReport(ur: UpdateReport, graphPath: File): Unit =
|
||||
{
|
||||
val str = toJsonString(toLite(ur))
|
||||
IO.write(graphPath, str, IO.utf8)
|
||||
IO.createDirectory(graphPath.getParentFile)
|
||||
toJsonFile(toLite(ur), graphPath)
|
||||
}
|
||||
def toLite(ur: UpdateReport): UpdateReportLite =
|
||||
UpdateReportLite(ur.configurations map { cr =>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ object Dependencies {
|
|||
lazy val ivy = "org.scala-sbt.ivy" % "ivy" % "2.3.0-sbt-fccfbd44c9f64523b61398a0155784dcbaeae28f"
|
||||
lazy val jsch = "com.jcraft" % "jsch" % "0.1.46" intransitive ()
|
||||
lazy val sbinary = "org.scala-tools.sbinary" %% "sbinary" % "0.4.2"
|
||||
lazy val sbtSerialization = "org.scala-sbt" %% "serialization" % "0.1.0"
|
||||
lazy val sbtSerialization = "org.scala-sbt" %% "serialization" % "0.1.1-1479903c3135da50e0442c91e707743311a4f362"
|
||||
lazy val scalaCompiler = Def.setting { "org.scala-lang" % "scala-compiler" % scalaVersion.value }
|
||||
lazy val testInterface = "org.scala-sbt" % "test-interface" % "1.0"
|
||||
lazy val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.11.4"
|
||||
|
|
|
|||
Loading…
Reference in New Issue