Skip to content

Commit

Permalink
Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Jul 11, 2023
1 parent fc899bd commit 1eb97c8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: playframework/.github/.github/workflows/cmd.yml@v3
with:
java: 17, 11
scala: 2.13.x
scala: 2.13.x, 3.x
cmd: sbt ++$MATRIX_SCALA test

finish:
Expand Down
21 changes: 17 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ lazy val commonSettings = Seq(
// Work around https://issues.scala-lang.org/browse/SI-9311
scalacOptions ~= (_.filterNot(_ == "-Xfatal-warnings")),
scalaVersion := "2.13.11", // scala213,
crossScalaVersions := Seq("2.13.11"), // scala213,
pomExtra := scala.xml.NodeSeq.Empty, // Can be removed when dropping interplay
crossScalaVersions := Seq("2.13.11", "3.3.0"), // scala213,
scalacOptions ++= {
if (scalaBinaryVersion.value == "3") {
Seq("-source:3.0-migration")
} else {
Nil
}
},
pomExtra := scala.xml.NodeSeq.Empty, // Can be removed when dropping interplay
developers += Developer(
"playframework",
"The Play Framework Contributors",
Expand All @@ -40,7 +47,7 @@ lazy val `play-slick-root` = (project in file("."))
lazy val `play-slick` = (project in file("src/core"))
.enablePlugins(PlayLibrary, Playdoc, MimaPlugin)
.configs(Docs)
.settings(libraryDependencies ++= Dependencies.core)
.settings(libraryDependencies ++= Dependencies.core.value)
.settings(mimaSettings)
.settings(commonSettings)

Expand Down Expand Up @@ -68,5 +75,11 @@ val previousVersion: Option[String] = Some("5.0.2")
ThisBuild / mimaFailOnNoPrevious := false

def mimaSettings = Seq(
mimaPreviousArtifacts := previousVersion.map(organization.value %% moduleName.value % _).toSet
mimaPreviousArtifacts := {
if (scalaBinaryVersion.value == "3") {
Set.empty // TODO
} else {
previousVersion.map(organization.value %% moduleName.value % _).toSet
}
}
)
45 changes: 27 additions & 18 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import sbt._
import Keys._

object Dependencies {
val core = Seq(
Library.slick,
Library.slickHikariCP,
Library.playCore,
Library.playJdbcApi,
Library.playLogback % "test",
Library.playSpecs2 % "test",
Library.h2 % "test"
val core = Def.setting(
Seq(
Library.slick.value,
Library.slickHikariCP.value,
Library.playCore,
Library.playJdbcApi,
Library.playLogback % "test",
Library.playSpecs2 % "test",
Library.h2 % "test"
)
)

val evolutions = Seq(
Expand All @@ -21,17 +24,23 @@ object Dependencies {
object Version {
val play = _root_.play.core.PlayVersion.current

val slick = "3.4.1"
val h2 = "2.2.220"
val slick = Def.setting(
if (scalaBinaryVersion.value == "3") {
"3.5.0-M4"
} else {
"3.4.1"
}
)
val h2 = "2.2.220"
}

object Library {
val playLogback = "com.typesafe.play" %% "play-logback" % Version.play
val playCore = "com.typesafe.play" %% "play" % Version.play
val playJdbcApi = "com.typesafe.play" %% "play-jdbc-api" % Version.play
val playJdbcEvolutions = "com.typesafe.play" %% "play-jdbc-evolutions" % Version.play
val playSpecs2 = "com.typesafe.play" %% "play-specs2" % Version.play
val slick = "com.typesafe.slick" %% "slick" % Version.slick
val slickHikariCP = "com.typesafe.slick" %% "slick-hikaricp" % Version.slick
val h2 = "com.h2database" % "h2" % Version.h2
val playLogback = "com.typesafe.play" %% "play-logback" % Version.play
val playCore = "com.typesafe.play" %% "play" % Version.play
val playJdbcApi = "com.typesafe.play" %% "play-jdbc-api" % Version.play
val playJdbcEvolutions = "com.typesafe.play" %% "play-jdbc-evolutions" % Version.play
val playSpecs2 = "com.typesafe.play" %% "play-specs2" % Version.play
val slick = Def.setting("com.typesafe.slick" %% "slick" % Version.slick.value)
val slickHikariCP = Def.setting("com.typesafe.slick" %% "slick-hikaricp" % Version.slick.value)
val h2 = "com.h2database" % "h2" % Version.h2
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ trait HasDatabaseConfig[P <: BasicProfile] {
@deprecated("Use `profile` instead of `driver`", "2.1")
protected final lazy val driver: P = dbConfig.profile // field is lazy to avoid early initializer problems.
/** The Slick database extracted from `dbConfig`. */
protected final def db: P#Backend#Database = dbConfig.db
protected final def db = dbConfig.db
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package play.api.db.slick

import java.util.concurrent.ConcurrentLinkedDeque

import org.specs2.mock.Mockito
import org.specs2.mutable.Specification
import play.api.inject.Injector
import play.api.inject.ApplicationLifecycle
import play.api.inject.DefaultApplicationLifecycle
import play.api.inject.guice.GuiceApplicationBuilder
import slick.basic.BasicProfile

class DefaultSlickApiSpec extends Specification with Mockito { self =>
class DefaultSlickApiSpec extends Specification { self =>

sequential

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SlickApiSpec extends Specification {
"return a DatabaseConfig instance for a correctly configured database" in {
import SUTWithGoodConfig._
val default = api.dbConfig[BasicProfile](DbName("default"))
default must not beNull
default must not(beNull)
}
"always return the same DatabaseConfig instance for a given database name" in {
import SUTWithGoodConfig._
Expand Down

0 comments on commit 1eb97c8

Please sign in to comment.