Skip to content

Commit

Permalink
update testPlayVersion command for Play 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dwickern committed Nov 3, 2023
1 parent 677c487 commit 3f3bf60
Showing 1 changed file with 44 additions and 36 deletions.
80 changes: 44 additions & 36 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ lazy val scala212 = "2.12.13"
lazy val scala213 = "2.13.4"
lazy val scala3 = "3.3.1"

// for running tests with a specific release; see testPlayVersionCommand
val playVersion = SettingKey[String]("play-version")

lazy val root = (project in file("."))
.aggregate(swagger.projectRefs: _*)
.settings(
Expand Down Expand Up @@ -47,12 +50,13 @@ lazy val swagger = (projectMatrix in file("."))
axisValues = Seq(play27, VirtualAxis.jvm),
_.settings(
moduleName := name.value + "2.7",
playVersion := "2.7.3",
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.3",
"com.typesafe.play" %% "play" % "2.7.3",
"com.typesafe.play" %% "routes-compiler" % "2.7.3",
"com.typesafe.play" %% "play-test" % "2.7.3" % Test,
"com.typesafe.play" %% "play-specs2" % "2.7.3" % Test,
"com.typesafe.play" %% "play" % playVersion.value,
"com.typesafe.play" %% "routes-compiler" % playVersion.value,
"com.typesafe.play" %% "play-test" % playVersion.value % Test,
"com.typesafe.play" %% "play-specs2" % playVersion.value % Test,
"com.typesafe.play" %% "play-ebean" % "5.0.2" % Test,
"io.swagger" % "swagger-core" % "1.5.24",
"io.swagger" %% "swagger-scala-module" % "1.0.6",
Expand All @@ -65,29 +69,40 @@ lazy val swagger = (projectMatrix in file("."))
axisValues = Seq(play28, VirtualAxis.jvm),
_.settings(
moduleName := name.value + "2.8",
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.3",
"com.typesafe.play" %% "play" % "2.8.0",
"com.typesafe.play" %% "routes-compiler" % "2.8.0",
"com.typesafe.play" %% "play-test" % "2.8.0" % Test,
"com.typesafe.play" %% "play-specs2" % "2.8.0" % Test,
"com.typesafe.play" %% "play-ebean" % "6.0.0" % Test,
"io.swagger" % "swagger-core" % "1.6.1",
"io.swagger" %% "swagger-scala-module" % "1.0.6", // FIXME: no version supports jackson 2.10
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.10.5",
)
playVersion := "2.8.0",
libraryDependencies ++= {
/** Extra dependencies needed for Play 2.8.8 */
val play288extras = if (VersionNumber(playVersion.value).matchesSemVer(SemanticSelector(">=2.8.8"))) {
Seq(
"io.swagger" % "swagger-core" % "1.6.2" % Provided,
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.11.1" % Provided
)
} else Seq.empty
Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.3",
"com.typesafe.play" %% "play" % playVersion.value,
"com.typesafe.play" %% "routes-compiler" % playVersion.value,
"com.typesafe.play" %% "play-test" % playVersion.value % Test,
"com.typesafe.play" %% "play-specs2" % playVersion.value % Test,
"com.typesafe.play" %% "play-ebean" % "6.0.0" % Test,
"io.swagger" % "swagger-core" % "1.6.1",
"io.swagger" %% "swagger-scala-module" % "1.0.6", // FIXME: no version supports jackson 2.10
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.10.5",
) ++ play288extras
}
)
)
.customRow(
scalaVersions = Seq(scala3, scala213),
axisValues = Seq(play29, VirtualAxis.jvm),
_.settings(
moduleName := name.value + "2.9",
playVersion := "2.9.0",
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % "2.9.0",
"com.typesafe.play" %% "play-routes-compiler" % "2.9.0",
"com.typesafe.play" %% "play-test" % "2.9.0" % Test,
"com.typesafe.play" %% "play-specs2" % "2.9.0" % Test,
"com.typesafe.play" %% "play" % playVersion.value,
"com.typesafe.play" %% "play-routes-compiler" % playVersion.value,
"com.typesafe.play" %% "play-test" % playVersion.value % Test,
"com.typesafe.play" %% "play-specs2" % playVersion.value % Test,
"com.typesafe.play" %% "play-ebean" % "7.0.0-RC2" % Test,
"io.swagger" % "swagger-core" % "1.6.11",
("io.swagger" %% "swagger-scala-module" % "1.0.6")
Expand All @@ -103,11 +118,12 @@ lazy val swagger = (projectMatrix in file("."))
axisValues = Seq(play30, VirtualAxis.jvm),
_.settings(
moduleName := name.value + "3.0",
playVersion := "3.0.0",
libraryDependencies ++= Seq(
"org.playframework" %% "play" % "3.0.0",
"org.playframework" %% "play-routes-compiler" % "3.0.0",
"org.playframework" %% "play-test" % "3.0.0" % Test,
"org.playframework" %% "play-specs2" % "3.0.0" % Test,
"org.playframework" %% "play" % playVersion.value,
"org.playframework" %% "play-routes-compiler" % playVersion.value,
"org.playframework" %% "play-test" % playVersion.value % Test,
"org.playframework" %% "play-specs2" % playVersion.value % Test,
"org.playframework" %% "play-ebean" % "8.0.0-M1" % Test,
"io.swagger" % "swagger-core" % "1.6.11",
("io.swagger" %% "swagger-scala-module" % "1.0.6")
Expand All @@ -125,28 +141,20 @@ lazy val swagger = (projectMatrix in file("."))
* Usage:
* sbt "testPlayVersion 2.8.8"
*/
lazy val testPlayVersionCommand = Command.single("testPlayVersion") { case (state, playVersion) =>
lazy val testPlayVersionCommand = Command.single("testPlayVersion") { case (state, version) =>
val matrix = Map(
SemanticSelector("2.7.x") -> play27,
SemanticSelector("2.8.x") -> play28,
SemanticSelector("2.9.x") -> play29,
SemanticSelector("3.0.x") -> play30,
)
val projectAxis = matrix
.collectFirst { case (sel, axis) if VersionNumber(playVersion).matchesSemVer(sel) => axis }
.getOrElse { throw new Exception(s"Unsupported Play version: $playVersion") }
.collectFirst { case (sel, axis) if VersionNumber(version).matchesSemVer(sel) => axis }
.getOrElse { throw new Exception(s"Unsupported Play version: $version") }

swagger.finder(projectAxis, VirtualAxis.jvm).get.foldLeft(state) { case (state, project) =>
/** Extra dependencies needed for Play 2.8.8 */
val play288extras = if (VersionNumber(playVersion).matchesSemVer(SemanticSelector(">=2.8.8"))) {
Seq(
"io.swagger" % "swagger-core" % "1.6.2",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.11.1"
)
} else Seq.empty
val newState = Project.extract(state).appendWithoutSession(Seq(
project / libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % playVersion,
) ++ play288extras
project / playVersion := version
), state)
Project.extract(newState).runAggregated(project / Test / test, newState)
}
Expand Down

0 comments on commit 3f3bf60

Please sign in to comment.