Skip to content

Commit

Permalink
Support for Play 3 (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmethvin authored May 10, 2024
1 parent 7682edf commit 035318c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Build and Test
strategy:
matrix:
scala: [2.12.13, 2.13.5]
scala: [2.13.14]

runs-on: ubuntu-latest
steps:
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Setup Java and Scala
uses: olafurpg/setup-scala@32ffa16635ff8f19cc21ea253a987f0fdf29844c
with:
java-version: adopt@1.8
java-version: adopt@1.11

- name: Cache sbt
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
Expand Down
12 changes: 6 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ developers := List(
Developer(id = "Iterable", name = "Iterable", email = "[email protected]", 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ 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 {
// TODO - it breaks on this, because
// 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 035318c

Please sign in to comment.