From 7089839dcfc1c91f195a4b1dcc6d7b60e40b210c Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Thu, 27 Jul 2017 19:56:40 -0700 Subject: replace pimp with 'rich', 'enrich', 'extension method' and: * add MiMa so we know the change is binary compatible * use current Scala & sbt versions --- .travis.yml | 2 +- CHANGELOG | 4 ++-- README.markdown | 2 +- build.sbt | 27 +++++++++++++++++++-------- notes/1.1.0.markdown | 2 +- project/build.properties | 2 +- project/plugins.sbt | 4 +++- src/main/scala/spray/json/package.scala | 24 +++++++++++++++++++++--- 8 files changed, 49 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c84d59..a4c0f79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: scala script: - - sbt "+ test" + - sbt "+ test" "+ mimaReportBinaryIssues" jdk: - oraclejdk8 notifications: diff --git a/CHANGELOG b/CHANGELOG index 8d988f5..bae279e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -Version 1.3.3 (1016-12-29) +Version 1.3.3 (2016-12-29) -------------------------- For Scala 2.12, this release brings no updates over 1.3.2 because the 2.12 release @@ -102,7 +102,7 @@ Version 1.1.1 (2012-03-13) Version 1.1.0 (2012-02-01) -------------------------- - Added automatic case class field name extraction via new jsonFormatX overloads -- Added 'asJson' pimp to Strings +- Added 'asJson' extension method to Strings - Added RootJsonFormat (JsonFormat for types corresponding to JSON document roots) - Fixed problem of JSON object deserialization not being member-order independent (removed JsField, turned JsObject(List[JsField]) into JsObject(Map[String, JsValue])) diff --git a/README.markdown b/README.markdown index e659e71..b840ac6 100644 --- a/README.markdown +++ b/README.markdown @@ -53,7 +53,7 @@ and do one or more of the following: val json = jsonAst.prettyPrint // or .compactPrint ``` -* Convert any Scala object to a JSON AST using the pimped `toJson` method +* Convert any Scala object to a JSON AST using the `toJson` extension method ```scala val jsonAst = List(1, 2, 3).toJson diff --git a/build.sbt b/build.sbt index 2e451e0..955fcca 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ name := "spray-json" -version := "1.3.3" +version := "1.3.4-SNAPSHOT" organization := "io.spray" @@ -14,7 +14,7 @@ startYear := Some(2011) licenses := Seq("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")) -scalaVersion := "2.11.8" +scalaVersion := "2.11.11" scalacOptions ++= Seq("-feature", "-language:_", "-unchecked", "-deprecation", "-Xlint", "-encoding", "utf8") @@ -44,28 +44,39 @@ osgiSettings OsgiKeys.exportPackage := Seq("""spray.json.*;version="${Bundle-Version}"""") -OsgiKeys.importPackage <<= scalaVersion { sv => Seq("""scala.*;version="$"""".format(sv)) } +OsgiKeys.importPackage := Seq("""scala.*;version="$"""".format(scalaVersion.value)) OsgiKeys.importPackage ++= Seq("""spray.json;version="${Bundle-Version}"""", "*") OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package") +// Migration Manager +mimaPreviousArtifacts := Set("io.spray" %% "spray-json" % "1.3.3") + /////////////// // publishing /////////////// -crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.1") +crossScalaVersions := Seq("2.10.6", "2.11.11", "2.12.3") -scalaBinaryVersion <<= scalaVersion(sV => if (CrossVersion.isStable(sV)) CrossVersion.binaryScalaVersion(sV) else sV) +scalaBinaryVersion := { + val sV = scalaVersion.value + if (CrossVersion.isScalaApiCompatible(sV)) + CrossVersion.binaryScalaVersion(sV) + else + sV +} publishMavenStyle := true useGpg := true -publishTo <<= version { v: String => +publishTo := { val nexus = "https://oss.sonatype.org/" - if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots") - else Some("releases" at nexus + "service/local/staging/deploy/maven2") + if (version.value.trim.endsWith("SNAPSHOT")) + Some("snapshots" at nexus + "content/repositories/snapshots") + else + Some("releases" at nexus + "service/local/staging/deploy/maven2") } pomIncludeRepository := { _ => false } diff --git a/notes/1.1.0.markdown b/notes/1.1.0.markdown index 2d09720..38b018c 100644 --- a/notes/1.1.0.markdown +++ b/notes/1.1.0.markdown @@ -4,7 +4,7 @@ and will have group id `cc.spray` rather than `cc.spray.json` as before. Changes since the last release (1.0.1): - Added automatic case class field name extraction via new `jsonFormatX` overloads -- Added `asJson` pimp to Strings +- Added `asJson` extension method to Strings - Added `RootJsonFormat` (`JsonFormat` for types corresponding to JSON document roots) - Fixed problem of JSON object deserialization not being member-order independent (removed `JsField`, turned `JsObject(List[JsField])` into `JsObject(Map[String, JsValue])`) diff --git a/project/build.properties b/project/build.properties index 817bc38..c091b86 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.9 +sbt.version=0.13.16 diff --git a/project/plugins.sbt b/project/plugins.sbt index b2c7588..b6edd90 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,4 +2,6 @@ addSbtPlugin("io.spray" % "sbt-boilerplate" % "0.5.9") addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.7.0") -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") \ No newline at end of file +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") + +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.18") diff --git a/src/main/scala/spray/json/package.scala b/src/main/scala/spray/json/package.scala index f79b99e..37d63c2 100644 --- a/src/main/scala/spray/json/package.scala +++ b/src/main/scala/spray/json/package.scala @@ -25,9 +25,14 @@ package object json { def jsonReader[T](implicit reader: JsonReader[T]) = reader def jsonWriter[T](implicit writer: JsonWriter[T]) = writer - - implicit def pimpAny[T](any: T) = new PimpedAny(any) - implicit def pimpString(string: String) = new PimpedString(string) + + implicit def enrichAny[T](any: T) = new RichAny(any) + implicit def enrichString(string: String) = new RichString(string) + + @deprecated("use enrichAny", "1.3.4") + def pimpAny[T](any: T) = new PimpedAny(any) + @deprecated("use enrichString", "1.3.4") + def pimpString(string: String) = new PimpedString(string) } package json { @@ -35,13 +40,26 @@ package json { case class DeserializationException(msg: String, cause: Throwable = null, fieldNames: List[String] = Nil) extends RuntimeException(msg, cause) class SerializationException(msg: String) extends RuntimeException(msg) + private[json] class RichAny[T](any: T) { + def toJson(implicit writer: JsonWriter[T]): JsValue = writer.write(any) + } + + private[json] class RichString(string: String) { + @deprecated("deprecated in favor of parseJson", "1.2.6") + def asJson: JsValue = parseJson + def parseJson: JsValue = JsonParser(string) + } + + @deprecated("use RichAny", "1.3.4") private[json] class PimpedAny[T](any: T) { def toJson(implicit writer: JsonWriter[T]): JsValue = writer.write(any) } + @deprecated("use RichString", "1.3.4") private[json] class PimpedString(string: String) { @deprecated("deprecated in favor of parseJson", "1.2.6") def asJson: JsValue = parseJson def parseJson: JsValue = JsonParser(string) } + } -- cgit v1.2.3