Skip to content

Commit

Permalink
Upgrade Play & Play JSON to 3.0 (#381)
Browse files Browse the repository at this point in the history
* 🏗️ build(play-json): upgrade to Play JSON 3.0

* 🏗️ build(play): bump to Play 3.0

* 📦 ci: fix sbt commands to run only for the scala version given as argument

* 📦 ci: run scalafmt and coverage on Scala 2.13

* 💎 style: disable scalafmt check on scala 3 macro
  • Loading branch information
gaeljw authored Nov 12, 2023
1 parent dba1630 commit 47dd3e1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 57 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ jobs:
shell: bash
run: |
case ${{ matrix.scala }} in
2.12.18)
sbt -v ++${{ matrix.scala }} scalafmtCheck scalafmtSbtCheck test:compile test:doc
sbt -v ++${{ matrix.scala }} coverage test coverageReport
sbt -v ++${{ matrix.scala }} coverageAggregate
2.13.11)
sbt -v "++${{ matrix.scala }} scalafmtCheck" "++${{ matrix.scala }} scalafmtSbtCheck" "++${{ matrix.scala }} test:compile" "++${{ matrix.scala }} test:doc"
sbt -v "coverage" "++${{ matrix.scala }} test" "++${{ matrix.scala }} coverageReport"
sbt -v "++${{ matrix.scala }} coverageAggregate"
;;
*)
sbt -v ++${{ matrix.scala }} test:compile test:doc
sbt -v ++${{ matrix.scala }} test
sbt -v "++${{ matrix.scala }} test:compile" "++${{ matrix.scala }} test:doc"
sbt -v "++${{ matrix.scala }} test"
;;
esac
rm -rf "$HOME/.ivy2/local" || true
Expand All @@ -52,7 +52,7 @@ jobs:
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
- name: Upload coverage to Codecov
if: ${{ matrix.scala == '2.12.18' }}
if: ${{ matrix.scala == '2.13.11' }}
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
50 changes: 11 additions & 39 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ lazy val theScalaVersion = scala_2_12Version

lazy val scalaTestVersion = "3.2.16"

def scalaTestPlay(scalaVersion: String) = CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor)) if scalaMajor >= 12 =>
"org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test

case Some((3, _)) =>
("org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test)
.cross(CrossVersion.for3Use2_13)
.exclude("org.scalactic", "*")
.exclude("org.scalatest", "*")
.exclude("org.scala-lang.modules", "*")
.exclude("com.typesafe.play", "play-json_2.13")

case _ =>
throw new IllegalArgumentException(s"Unsupported Scala version $scalaVersion for play-test")
}

lazy val baseProjectRefs =
Seq(macrosJS, macrosJVM, macrosNative, coreJS, coreJVM, coreNative, coreJVMTests).map(
Project.projectToRef
Expand Down Expand Up @@ -285,15 +269,11 @@ lazy val enumeratumPlayJson = crossProject(JSPlatform, JVMPlatform)
.settings(testSettings)
.jsSettings(jsTestSettings)
.settings(
name := "enumeratum-play-json",
version := Versions.Core.head,
crossScalaVersions := Seq(
scala_2_12Version,
scala_2_13Version,
scala_3Version
),
name := "enumeratum-play-json",
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= Seq(
"com.typesafe.play" %%% "play-json" % "2.10.1",
"org.playframework" %%% "play-json" % "3.0.0",
scalaXmlTest
),
libraryDependencies ++= {
Expand All @@ -319,21 +299,13 @@ lazy val enumeratumPlay = Project(id = "enumeratum-play", base = file("enumeratu
.settings(commonWithPublishSettings)
.settings(testSettings)
.settings(
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies += {
val dep = ("com.typesafe.play" %% "play" % "2.8.0").exclude("org.scala-lang.modules", "*")

if (scalaBinaryVersion.value == "3") {
dep
.exclude("org.scala-lang.modules", "*")
.exclude("com.typesafe.play", "play-json_2.13")
.cross(CrossVersion.for3Use2_13)
} else {
dep
}
},
libraryDependencies += scalaTestPlay(scalaVersion.value),
version := Versions.Core.head,
// Play do not support 2.12 (default from common settings)
scalaVersion := scala_2_13Version,
crossScalaVersions := Seq(scala_2_13Version, scala_3Version),
libraryDependencies += ("org.playframework" %% "play" % "3.0.0")
.exclude("org.scala-lang.modules", "*"),
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "7.0.0" % Test,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
Expand Down
2 changes: 2 additions & 0 deletions enumeratum-core/src/main/scala-3/enumeratum/EnumCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package enumeratum

private[enumeratum] trait EnumCompat[A <: EnumEntry] { _enum: Enum[A] =>

// format: off
/** Returns a Seq of [[A]] objects that the macro was able to find.
*
* You will want to use this in some way to implement your [[values]] method. In fact, if you
* aren't using this method... why are you even bothering with this lib?
*/
inline def findValues: IndexedSeq[A] = ${ EnumMacros.findValuesImpl[A] }
// format: on

/** The sequence of values for your [[Enum]]. You will typically want to implement this in your
* extending class as a `val` so that `withName` and friends are as efficient as possible.
Expand Down
11 changes: 0 additions & 11 deletions enumeratum-play/compat/src/test/scala-2.12/ActionHelper.scala

This file was deleted.

0 comments on commit 47dd3e1

Please sign in to comment.