mirror of https://github.com/sbt/sbt.git
Remove custom picklers
- sbt/serialization supports these
This commit is contained in:
parent
40b65c914a
commit
fdea36118d
|
|
@ -126,7 +126,7 @@ object Artifact {
|
|||
val tag = implicitly[FastTypeTag[Artifact]]
|
||||
def unpickle(tpe: String, reader: PReader): Any = {
|
||||
reader.pushHints()
|
||||
reader.hintTag(tag)
|
||||
// reader.hintTag(tag)
|
||||
reader.beginEntry()
|
||||
val name = stringPickler.unpickleEntry(reader.readField("name")).asInstanceOf[String]
|
||||
val tp = stringPickler.unpickleEntry(reader.readField("type")).asInstanceOf[String]
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
package sbt
|
||||
|
||||
import sbt.serialization._
|
||||
import java.{ util => ju }
|
||||
|
||||
private[sbt] object DatePicklers {
|
||||
private val longTag = implicitly[FastTypeTag[Long]]
|
||||
implicit val datePickler: Pickler[ju.Date] = new Pickler[ju.Date] {
|
||||
val tag = implicitly[FastTypeTag[ju.Date]]
|
||||
def pickle(a: ju.Date, builder: PBuilder): Unit = {
|
||||
builder.pushHints()
|
||||
builder.hintTag(tag)
|
||||
builder.beginEntry(a)
|
||||
builder.putField("value", { b =>
|
||||
b.hintTag(longTag)
|
||||
longPickler.pickle(a.getTime, b)
|
||||
})
|
||||
builder.endEntry()
|
||||
builder.popHints()
|
||||
}
|
||||
}
|
||||
implicit val dateUnpickler: Unpickler[ju.Date] = new Unpickler[ju.Date] {
|
||||
val tag = implicitly[FastTypeTag[ju.Date]]
|
||||
def unpickle(tpe: String, reader: PReader): Any = {
|
||||
reader.pushHints()
|
||||
reader.hintTag(tag)
|
||||
reader.beginEntry()
|
||||
val a0 = longPickler.unpickleEntry(reader.readField("value")).asInstanceOf[Long]
|
||||
val result = new ju.Date(a0)
|
||||
reader.endEntry()
|
||||
reader.popHints()
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package sbt
|
||||
|
||||
import java.io.File
|
||||
import sbt.serialization._
|
||||
import java.net.URI
|
||||
|
||||
object FileMapPicklers {
|
||||
implicit def fileMapPickler[A: Pickler: Unpickler: FastTypeTag]: Pickler[Map[File, A]] with Unpickler[Map[File, A]] = new Pickler[Map[File, A]] with Unpickler[Map[File, A]] {
|
||||
val tag = implicitly[FastTypeTag[Map[File, A]]]
|
||||
val stringAMapPickler = implicitly[Pickler[Map[String, A]]]
|
||||
val stringAMapUnpickler = implicitly[Unpickler[Map[String, A]]]
|
||||
|
||||
def pickle(m: Map[File, A], builder: PBuilder): Unit =
|
||||
stringAMapPickler.pickle(Map(m.toSeq map { case (k, v) => (k.toURI.toASCIIString, v) }: _*), builder)
|
||||
|
||||
def unpickle(tpe: String, reader: PReader): Any =
|
||||
Map(stringAMapUnpickler.unpickle(tpe, reader).asInstanceOf[Map[String, A]].toSeq map {
|
||||
case (k, v) =>
|
||||
(new File(new URI(k)), v)
|
||||
}: _*).asInstanceOf[Map[File, A]]
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package sbt
|
||||
|
||||
import sbt.serialization._
|
||||
|
||||
private[sbt] object PairPicklers {
|
||||
implicit def pairPickler[A1: FastTypeTag: Pickler: Unpickler, A2: FastTypeTag: Pickler: Unpickler](): Pickler[(A1, A2)] with Unpickler[(A1, A2)] =
|
||||
new Pickler[(A1, A2)] with Unpickler[(A1, A2)] {
|
||||
val a1Tag = implicitly[FastTypeTag[A1]]
|
||||
val a2Tag = implicitly[FastTypeTag[A2]]
|
||||
val tag = implicitly[FastTypeTag[(A1, A2)]]
|
||||
val a1Pickler = implicitly[Pickler[A1]]
|
||||
val a1Unpickler = implicitly[Unpickler[A1]]
|
||||
val a2Pickler = implicitly[Pickler[A2]]
|
||||
val a2Unpickler = implicitly[Unpickler[A2]]
|
||||
|
||||
def pickle(a: (A1, A2), builder: PBuilder): Unit = {
|
||||
builder.pushHints()
|
||||
builder.hintTag(tag)
|
||||
builder.beginEntry(a)
|
||||
builder.putField("_1", { b =>
|
||||
b.hintTag(a1Tag)
|
||||
a1Pickler.pickle(a._1, b)
|
||||
})
|
||||
builder.putField("_2", { b =>
|
||||
b.hintTag(a2Tag)
|
||||
a2Pickler.pickle(a._2, b)
|
||||
})
|
||||
builder.endEntry()
|
||||
builder.popHints()
|
||||
}
|
||||
|
||||
def unpickle(tpe: String, reader: PReader): Any = {
|
||||
reader.pushHints()
|
||||
reader.hintTag(tag)
|
||||
reader.beginEntry()
|
||||
val a0 = a1Unpickler.unpickleEntry(reader.readField("_1")).asInstanceOf[A1]
|
||||
val a1 = a2Unpickler.unpickleEntry(reader.readField("_2")).asInstanceOf[A2]
|
||||
val result = (a0, a1)
|
||||
reader.endEntry()
|
||||
reader.popHints()
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -159,13 +159,6 @@ object ModuleReport {
|
|||
def apply(module: ModuleID, artifacts: Seq[(Artifact, File)], missingArtifacts: Seq[Artifact]): ModuleReport =
|
||||
new ModuleReport(module, artifacts, missingArtifacts, None, None, None, None,
|
||||
false, None, None, None, None, Map(), None, None, Nil, Nil, Nil)
|
||||
|
||||
import PairPicklers._
|
||||
import DatePicklers._
|
||||
private implicit val afPairPickler: Pickler[(Artifact, File)] with Unpickler[(Artifact, File)] =
|
||||
pairPickler[Artifact, File]
|
||||
private implicit def tuplePickler2: Pickler[(String, Option[String])] with Unpickler[(String, Option[String])] =
|
||||
pairPickler[String, Option[String]]
|
||||
implicit val pickler: Pickler[ModuleReport] with Unpickler[ModuleReport] = PicklerUnpickler.generate[ModuleReport]
|
||||
}
|
||||
|
||||
|
|
@ -289,7 +282,6 @@ object UpdateReport {
|
|||
}
|
||||
}
|
||||
|
||||
import FileMapPicklers._
|
||||
private val vectorConfigurationReportPickler = implicitly[Pickler[Vector[ConfigurationReport]]]
|
||||
private val vectorConfigurationReportUnpickler = implicitly[Unpickler[Vector[ConfigurationReport]]]
|
||||
private val updateStatsPickler = implicitly[Pickler[UpdateStats]]
|
||||
|
|
|
|||
|
|
@ -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.1-1479903c3135da50e0442c91e707743311a4f362"
|
||||
lazy val sbtSerialization = "org.scala-sbt" %% "serialization" % "0.1.1"
|
||||
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