From 9c65f7b9289b4836e6a892a968ea0759d0f5e671 Mon Sep 17 00:00:00 2001 From: Greg Methvin Date: Thu, 9 May 2024 14:28:19 -0700 Subject: [PATCH] Support for Play 3 --- build.sbt | 12 ++++++------ .../com/iterable/play/utils/CaseClassMapping.scala | 2 +- .../iterable/play/utils/CaseClassMappingSpec.scala | 8 ++++---- .../play/utils/UnbindableToWsRequestSpec.scala | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build.sbt b/build.sbt index 4d0bcf0..bc3f954 100644 --- a/build.sbt +++ b/build.sbt @@ -10,17 +10,17 @@ developers := List( Developer(id = "Iterable", name = "Iterable", email = "engineering@iterable.com", url = url("https://iterable.com")) ) -scalaVersion := "2.13.5" -crossScalaVersions := Seq(scalaVersion.value, "2.12.13") +scalaVersion := "2.13.14" +crossScalaVersions := Seq(scalaVersion.value) -val PlayVersion = "2.8.6" +val PlayVersion = "3.0.1" libraryDependencies ++= Seq( // Play! framework - "com.typesafe.play" %% "play" % PlayVersion, - "com.typesafe.play" %% "play-joda-forms" % PlayVersion, + "org.playframework" %% "play" % PlayVersion, + "org.playframework" %% "play-joda-forms" % PlayVersion, // dependencies for tests - "org.scalatest" %% "scalatest" % "3.2.5" % Test + "org.scalatest" %% "scalatest" % "3.2.18" % Test ) parallelExecution in Test := false diff --git a/src/main/scala/com/iterable/play/utils/CaseClassMapping.scala b/src/main/scala/com/iterable/play/utils/CaseClassMapping.scala index dd255f8..0f9ef1e 100644 --- a/src/main/scala/com/iterable/play/utils/CaseClassMapping.scala +++ b/src/main/scala/com/iterable/play/utils/CaseClassMapping.scala @@ -64,7 +64,7 @@ object CaseClassMapping extends Logging { } private def generateWrappedMappingForFormatter(fieldName: String, tpe: Type, formatter: Formatter[_]): Mapping[_] = { - val mapping = FieldMapping("")(formatter.asInstanceOf[Formatter[Any]]) + @annotation.nowarn val mapping = FieldMapping("")(formatter.asInstanceOf[Formatter[Any]]) generateWrappedMappingForMapping(fieldName, tpe, mapping) } diff --git a/src/test/scala/com/iterable/play/utils/CaseClassMappingSpec.scala b/src/test/scala/com/iterable/play/utils/CaseClassMappingSpec.scala index dc778a3..81fe163 100644 --- a/src/test/scala/com/iterable/play/utils/CaseClassMappingSpec.scala +++ b/src/test/scala/com/iterable/play/utils/CaseClassMappingSpec.scala @@ -7,17 +7,17 @@ import play.api.data.{Form, FormError, Mapping} case class Baz(pls: String, work: Option[Long]) object Baz { - implicit val mapping = CaseClassMapping.mapping[Baz] + implicit val mapping: CaseClassMapping[Baz] = CaseClassMapping.mapping } case class Foo(a: String, omg: Option[Seq[Baz]]) object Foo { - implicit def mapping = CaseClassMapping.mapping[Foo] + implicit def mapping: CaseClassMapping[Foo] = CaseClassMapping.mapping } case class Bar(firstOne: Option[List[Long]], secondOne: String, third: Option[Foo], fourth: Option[Int]) extends UnbindableToWsRequest[Bar] object Bar { - implicit val mapping = CaseClassMapping.mapping[Bar] + implicit val mapping: CaseClassMapping[Bar] = CaseClassMapping.mapping } class CaseClassMappingSpec extends AnyWordSpec with Matchers { @@ -25,7 +25,7 @@ class CaseClassMappingSpec extends AnyWordSpec with Matchers { // scala.ScalaReflectionException: class Bar2 is an inner class, use reflectClass on an InstanceMirror to obtain its ClassMirror case class Bar2(firstOne: Int) object Bar2 { - implicit lazy val mapping = CaseClassMapping.mapping[Bar2] + implicit lazy val mapping: CaseClassMapping[Bar2] = CaseClassMapping.mapping } "CaseClassMapping" should { diff --git a/src/test/scala/com/iterable/play/utils/UnbindableToWsRequestSpec.scala b/src/test/scala/com/iterable/play/utils/UnbindableToWsRequestSpec.scala index 0435105..754e4a3 100644 --- a/src/test/scala/com/iterable/play/utils/UnbindableToWsRequestSpec.scala +++ b/src/test/scala/com/iterable/play/utils/UnbindableToWsRequestSpec.scala @@ -5,7 +5,7 @@ import org.scalatest.wordspec.AnyWordSpec case class User(name: String, age: Int, email: String, favoriteBands: Seq[String]) extends UnbindableToWsRequest[User] object User { - implicit val mapping = CaseClassMapping.mapping[User] + implicit val mapping: CaseClassMapping[User] = CaseClassMapping.mapping } class UnbindableToWsRequestSpec extends AnyWordSpec with Matchers {