Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: Scala3 migration #728

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,16 @@ bin
.idea

.bsp/

# vscode
.vscode/

# metals
.metals/
project/metals.sbt
project/project

# bloop
.bloop/
project/.bloop/

20 changes: 14 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import scala.sys.process._

import com.typesafe.tools.mima.plugin.MimaPlugin._
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters
import interplay.ScalaVersions._

ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("releases")
Expand All @@ -18,8 +17,8 @@ Global / onLoad := (Global / onLoad).value.andThen { s =>
lazy val commonSettings = Seq(
// Work around https://issues.scala-lang.org/browse/SI-9311
scalacOptions ~= (_.filterNot(_ == "-Xfatal-warnings")),
scalaVersion := "2.13.10", // scala213,
crossScalaVersions := Seq("2.13.10"), // scala213,
scalaVersion := scala213,
crossScalaVersions := Seq(scala213, scala3),
pomExtra := scala.xml.NodeSeq.Empty, // Can be removed when dropping interplay
developers += Developer(
"playframework",
Expand All @@ -42,6 +41,11 @@ lazy val `play-slick` = (project in file("src/core"))
.configs(Docs)
.settings(libraryDependencies ++= Dependencies.core)
.settings(mimaSettings)
.settings(
mimaBinaryIssueFilters ++= Seq(
ProblemFilters.exclude[DirectMissingMethodProblem]("play.api.db.slick.HasDatabaseConfig.db")
)
)
.settings(commonSettings)

lazy val `play-slick-evolutions` = (project in file("src/evolutions"))
Expand All @@ -68,5 +72,9 @@ 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[ModuleID]
else
previousVersion.map(organization.value %% moduleName.value % _).toSet
}
)
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Dependencies {
object Version {
val play = _root_.play.core.PlayVersion.current

val slick = "3.4.1"
val slick = "3.5.0-pre.66.7d3ce9c0"
val h2 = "2.1.214"
}

Expand Down
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"), // used by deploy nightlies, which publish here & use -Dplay.version
)

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % sys.props.getOrElse("play.version", "2.9.0-M3"))
addSbtPlugin("com.typesafe.play" % "play-docs-sbt-plugin" % sys.props.getOrElse("play.version", "2.9.0-M3"))
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % sys.props.getOrElse("play.version", "2.9.0-M4"))
addSbtPlugin("com.typesafe.play" % "play-docs-sbt-plugin" % sys.props.getOrElse("play.version", "2.9.0-M4"))
addSbtPlugin("com.typesafe.play" % "interplay" % sys.props.get("interplay.version").getOrElse("3.1.0-RC10"))

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@ object DatabaseConfigProvider {
trait HasDatabaseConfig[P <: BasicProfile] {

/** The Slick database configuration. */
protected val dbConfig: DatabaseConfig[P] // field is declared as a val because we want a stable identifier.
protected lazy val dbConfig: DatabaseConfig[P] =
??? // field is declared as a val because we want a stable identifier. TODO: Remove ??? when dropping Scala 2
/** The Slick profile extracted from `dbConfig`. */
protected final lazy val profile: P = dbConfig.profile // field is lazy to avoid early initializer problems.
@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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understood that this is Path Dependent Types but I didn't find a way to make it work. Any insight here would be much appreciated!

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