Skip to content
Merged
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: 0 additions & 2 deletions .github/scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ updates.pin = [
{ groupId = "com.typesafe.play", artifactId = "play-specs2", version = "2.9." },
{ groupId = "com.typesafe.play", artifactId = "sbt-plugin", version = "2.9." }
]

updatePullRequests = never
7 changes: 7 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ rewrite.rules = [ AvoidInfix, ExpandImportSelectors, RedundantParens, SortModifi
rewrite.sortModifiers.order = [ "private", "protected", "final", "sealed", "abstract", "implicit", "override", "lazy" ]
spaces.inImportCurlyBraces = true # more idiomatic to include whitepsace in import x.{ yyy }
trailingCommas = preserve
rewrite.scala3.convertToNewSyntax = true
rewrite.scala3.newSyntax.control = false
runner.dialectOverride {
allowSignificantIndentation = false
allowAsForImportRename = false
allowStarWildcardImport = false
}
31 changes: 19 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import scala.sys.process._

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

ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("releases")

// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
ThisBuild / dynverVTagPrefix := false
Expand All @@ -17,29 +13,42 @@ 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")),
organization := "com.typesafe.play",
organizationName := "The Play Framework Project",
organizationHomepage := Some(url("https://playframework.com/")),
homepage := Some(url(s"https://github.com/playframework/${Common.repoName}")),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")),
javacOptions ++= Seq("-encoding", "UTF-8", "-Xlint:-options"),
compile / javacOptions ++= Seq("--release", "11"),
doc / javacOptions := Seq("-source", "11"),
scalaVersion := "2.13.16",
crossScalaVersions := Seq("2.13.16", "3.3.6"),
pomExtra := scala.xml.NodeSeq.Empty, // Can be removed when dropping interplay
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-encoding", "utf8") ++
(CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => Seq("-Xsource:3")
case _ => Seq.empty
}),
developers += Developer(
"playframework",
"The Play Framework Contributors",
"contact@playframework.com",
url("https://github.com/playframework")
),
pomIncludeRepository := { _ => false }
)

lazy val `play-slick-root` = (project in file("."))
.enablePlugins(PlayRootProject)
.aggregate(
`play-slick`,
`play-slick-evolutions`
)
.settings(commonSettings)
.settings(
publish / skip := true
)

lazy val `play-slick` = (project in file("src/core"))
.enablePlugins(PlayLibrary, Playdoc, MimaPlugin)
.enablePlugins(Omnidoc, Playdoc, MimaPlugin)
.configs(Docs)
.settings(libraryDependencies ++= Dependencies.core)
.settings(mimaSettings)
Expand All @@ -51,7 +60,7 @@ lazy val `play-slick` = (project in file("src/core"))
.settings(commonSettings)

lazy val `play-slick-evolutions` = (project in file("src/evolutions"))
.enablePlugins(PlayLibrary, Playdoc, MimaPlugin)
.enablePlugins(Omnidoc, Playdoc, MimaPlugin)
.configs(Docs)
.settings(libraryDependencies ++= Dependencies.evolutions)
.settings(mimaSettings)
Expand All @@ -66,8 +75,6 @@ lazy val docs = project
.dependsOn(`play-slick-evolutions`)
.settings(commonSettings)

ThisBuild / playBuildRepoName := "play-slick"

// Binary compatibility is tested against this version
val previousVersion: Option[String] = Some("5.2.0")

Expand Down
4 changes: 3 additions & 1 deletion project/CommonSettings.scala β†’ project/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import sbt._

import sbt.Keys._

object CommonSettings extends AutoPlugin {
object Common extends AutoPlugin {

val repoName = "play-slick"

override def requires = plugins.JvmPlugin
override def trigger = allRequirements
Expand Down
53 changes: 53 additions & 0 deletions project/Omnidoc.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import sbt._
import sbt.Keys._
import sbt.Package.ManifestAttributes

/**
* This AutoPlugin adds the `Omnidoc-Source-URL` key on the MANIFEST.MF of artifact-sources.jar so later Omnidoc can use
* that value to link scaladocs to GitHub sources.
*/
object Omnidoc extends AutoPlugin {

object autoImport {
lazy val omnidocSnapshotBranch = settingKey[String]("Git branch for development versions")
lazy val omnidocPathPrefix = settingKey[String]("Prefix before source directory paths")
lazy val omnidocSourceUrl = settingKey[Option[String]]("Source URL for scaladoc linking")
}

val omnidocGithubRepo: Option[String] = Some(s"playframework/${Common.repoName}")

val omnidocTagPrefix: Option[String] = Some("")

val SourceUrlKey = "Omnidoc-Source-URL"

override def requires = sbt.plugins.JvmPlugin

override def trigger = noTrigger

import autoImport.*

override def projectSettings = Seq(
omnidocSourceUrl := omnidocGithubRepo.map { repo =>
val development: String = (omnidocSnapshotBranch ?? "main").value
val tagged: String = omnidocTagPrefix.getOrElse("v") + version.value
val tree: String = if (isSnapshot.value) development else tagged
val prefix: String = "/" + (omnidocPathPrefix ?? "").value
val path: String = {
val buildDir: File = (ThisBuild / baseDirectory).value
val projDir: File = baseDirectory.value
val rel: Option[String] = IO.relativize(buildDir, projDir)
rel match {
case None if buildDir == projDir => "" // Same dir (sbt 0.13)
case Some("") => "" // Same dir (sbt 1.0)
case Some(childDir) => prefix + childDir // Child dir
case None => "" // Disjoint dirs (Rich: I'm not sure if this can happen)
}
}
s"https://github.com/${repo}/tree/${tree}${path}"
},
Compile / packageSrc / packageOptions ++= omnidocSourceUrl.value.toSeq.map { url =>
ManifestAttributes(SourceUrlKey -> url)
}
)

}
32 changes: 32 additions & 0 deletions project/Playdoc.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sbt._
import sbt.Keys._
import sbt.io.IO

object Playdoc extends AutoPlugin {

object autoImport {
final val Docs = config("docs")
val playdocDirectory = settingKey[File]("Base directory of play documentation")
val playdocPackage = taskKey[File]("Package play documentation")
}

import autoImport.*

override def requires = sbt.plugins.JvmPlugin

override def trigger = noTrigger

override def projectSettings =
Defaults.packageTaskSettings(playdocPackage, playdocPackage / mappings) ++
Seq(
playdocDirectory := (ThisBuild / baseDirectory).value / "docs" / "manual",
playdocPackage / mappings := {
val base: File = playdocDirectory.value
base.allPaths.pair(IO.relativize(base.getParentFile(), _))
},
playdocPackage / artifactClassifier := Some("playdoc"),
playdocPackage / artifact ~= { _.withConfigurations(Vector(Docs)) }
) ++
addArtifact(playdocPackage / artifact, playdocPackage)

}
6 changes: 2 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
resolvers ++= DefaultOptions.resolvers(snapshot = true)
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots"), // used by deploy nightlies, which publish here & use -Dplay.version
Resolver.sonatypeCentralSnapshots, // used by deploy nightlies, which publish here & use -Dplay.version
)

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % sys.props.getOrElse("play.version", "2.9.8"))
addSbtPlugin("com.typesafe.play" % "play-docs-sbt-plugin" % sys.props.getOrElse("play.version", "2.9.8"))
addSbtPlugin("com.typesafe.play" % "interplay" % sys.props.get("interplay.version").getOrElse("3.1.7"))

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4")

addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.3")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.1")
2 changes: 1 addition & 1 deletion src/core/src/main/scala/play/api/db/slick/SlickApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object DefaultSlickApi {
}
}

private def registerDatabaseShutdownHook(dbConf: DatabaseConfig[_]): Unit = {
private def registerDatabaseShutdownHook(dbConf: DatabaseConfig[?]): Unit = {
// clean-up when the application is stopped.
lifecycle.addStopHook { () =>
Future {
Expand Down
6 changes: 3 additions & 3 deletions src/core/src/main/scala/play/api/db/slick/SlickModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object SlickModule {

@Singleton
final class SlickModule extends Module {
def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = {
def bindings(environment: Environment, configuration: Configuration): Seq[Binding[?]] = {
val config = configuration.underlying
val dbKey = config.getString(SlickModule.DbKeyConfig)
val default = config.getString(SlickModule.DefaultDbName)
Expand All @@ -44,11 +44,11 @@ final class SlickModule extends Module {
)
}

def namedDatabaseConfigBindings(dbs: Set[String]): Seq[Binding[_]] = dbs.toList.map { db =>
def namedDatabaseConfigBindings(dbs: Set[String]): Seq[Binding[?]] = dbs.toList.map { db =>
bindNamed(db).to(new NamedDatabaseConfigProvider(db))
}

def defaultDatabaseConfigBinding(default: String, dbs: Set[String]): Seq[Binding[_]] =
def defaultDatabaseConfigBinding(default: String, dbs: Set[String]): Seq[Binding[?]] =
if (dbs.contains(default)) Seq(bind[DatabaseConfigProvider].to(bindNamed(default))) else Nil

def bindNamed(name: String): BindingKey[DatabaseConfigProvider] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class DefaultSlickApiSpec extends Specification { self =>
// A new injector should be created to ensure each test is independent of each other
def injector: Injector = GuiceApplicationBuilder(configuration = TestData.configuration).injector()

def hooks(lifecycle: DefaultApplicationLifecycle): Seq[_] = {
def hooks(lifecycle: DefaultApplicationLifecycle): Seq[?] = {
val hooksField = lifecycle.getClass.getDeclaredField("hooks")
hooksField.setAccessible(true)
hooksField.get(lifecycle).asInstanceOf[ConcurrentLinkedDeque[_]].toArray().toSeq
hooksField.get(lifecycle).asInstanceOf[ConcurrentLinkedDeque[?]].toArray().toSeq
}

"DefaultSlickApi" should {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import play.api.inject.Module

@Singleton
class EvolutionsModule extends Module {
def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = {
def bindings(environment: Environment, configuration: Configuration): Seq[Binding[?]] = {
Seq(bind[DBApi].to[DBApiAdapter].in[Singleton])
}
}
Expand Down
Loading