Skip to content

Commit

Permalink
Merge pull request #12408 from playframework/mergify/bp/2.9.x/pr-12401
Browse files Browse the repository at this point in the history
[2.9.x] Upgrade to latest scala versions (backport #12401) by @mkurz
  • Loading branch information
mkurz committed Feb 26, 2024
2 parents 0a76dbe + 4cdd012 commit eaa143f
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 24 deletions.
3 changes: 2 additions & 1 deletion core/play/src/main/scala/play/api/controllers/Assets.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import akka.stream.scaladsl.StreamConverters
import play.api._
import play.api.http._
import play.api.inject.ApplicationLifecycle
import play.api.inject.Binding
import play.api.inject.Module
import play.api.libs._
import play.api.mvc._
Expand All @@ -42,7 +43,7 @@ import play.utils.Resources
import play.utils.UriEncoding

class AssetsModule extends Module {
override def bindings(environment: Environment, configuration: Configuration) = Seq(
override def bindings(environment: Environment, configuration: Configuration): scala.collection.Seq[Binding[_]] = Seq(
bind[Assets].toSelf,
bind[AssetsMetadata].toProvider[AssetsMetadataProvider],
bind[AssetsFinder].toProvider[AssetsFinderProvider],
Expand Down
3 changes: 2 additions & 1 deletion core/play/src/main/scala/play/api/i18n/I18nModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
package play.api.i18n

import play.api.http.HttpConfiguration
import play.api.inject.Binding
import play.api.inject.Module
import play.api.Configuration
import play.api.Environment

class I18nModule extends Module {
def bindings(environment: Environment, configuration: Configuration) = {
def bindings(environment: Environment, configuration: Configuration): scala.collection.Seq[Binding[_]] = {
Seq(
bind[Langs].toProvider[DefaultLangsProvider],
bind[MessagesApi].toProvider[DefaultMessagesApiProvider],
Expand Down
5 changes: 4 additions & 1 deletion core/play/src/main/scala/play/api/inject/Module.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ abstract class Module {
class SimpleModule(bindingsFunc: (Environment, Configuration) => Seq[Binding[_]]) extends Module {
def this(bindings: Binding[_]*) = this((_, _) => bindings)

final override def bindings(environment: Environment, configuration: Configuration) =
final override def bindings(
environment: Environment,
configuration: Configuration
): scala.collection.Seq[Binding[_]] =
bindingsFunc(environment, configuration)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ trait PathPart
* @param encode Whether this part should be encoded or not.
*/
case class DynamicPart(name: String, constraint: String, encode: Boolean) extends PathPart with Positional {
override def toString = """DynamicPart("""" + name + "\", \"\"\"" + constraint + "\"\"\"," + encode + ")" // "
override def toString =
"""DynamicPart("""" + name + "\", \"\"\"" + constraint + "\"\"\", encodeable=" + encode + ")" // "
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ object RouterSpec extends PlaySpecification {
whenNoValue: Future[play.api.mvc.Result] => Any,
whenNoParam: Future[play.api.mvc.Result] => Any
) =
testQueryParamBinding(paramType, path, successParams, expectationSuccess, whenNoValue, whenNoParam, true)
testQueryParamBinding(paramType, path, successParams, expectationSuccess, whenNoValue, whenNoParam, withDefault = true)

private def testQueryParamBinding(
paramType: String,
Expand Down
4 changes: 2 additions & 2 deletions documentation/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ lazy val main = Project("Play-Documentation", file("."))
Test / unmanagedResourceDirectories ++= (baseDirectory.value / "manual" / "detailedTopics" ** "code").get,
// Don't include sbt files in the resources
Test / unmanagedResources / excludeFilter := (Test / unmanagedResources / excludeFilter).value || "*.sbt",
crossScalaVersions := Seq("2.13.12", "3.3.1"),
scalaVersion := "2.13.12",
crossScalaVersions := Seq("2.13.13", "3.3.2"),
scalaVersion := "2.13.13",
Test / fork := true,
Test / javaOptions ++= Seq("-Xmx512m", "-Xms128m"),
headerLicense := Some(
Expand Down
2 changes: 1 addition & 1 deletion documentation/manual/hacking/BuildingFromSource.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This will build and publish Play for the default Scala version. If you want to p
Or to publish for a specific Scala version:

```bash
> ++ 2.13.12 publishLocal
> ++ 2.13.13 publishLocal
```

## Build the documentation
Expand Down
2 changes: 1 addition & 1 deletion documentation/manual/releases/Scala3Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In addition to the migration steps mentioned on this page, which cover the migra
To set the Scala version in sbt, simply set the `scalaVersion` key, for example:

```scala
scalaVersion := "3.3.1"
scalaVersion := "3.3.2"
```

> It's important to emphasize that Play exclusively supports [Scala LTS (Long-Term Support)](https://www.scala-lang.org/blog/2022/08/17/long-term-compatibility-plans.html) versions. As a result, any Scala release between Scala 3.3 LTS and the subsequent LTS version will not be officially supported by Play. However, it might still be feasible to use Play with such Scala versions. You may be interested in "[The Scala 3 compatibility story](https://virtuslab.com/blog/the-scala-3-compatibility-story/)" and the [Scala 3.3 release blog post](https://scala-lang.org/blog/2023/05/30/scala-3.3.0-released.html).
Expand Down
4 changes: 2 additions & 2 deletions documentation/manual/releases/release26/Highlights26.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can select which version of Scala you would like to use by setting the `scal
For Scala 2.12:

```scala
scalaVersion := "2.12.18"
scalaVersion := "2.12.19"
```

For Scala 2.11:
Expand All @@ -31,7 +31,7 @@ lazy val root = (project in file("."))
.enablePlugins(PlayService)
.enablePlugins(RoutesCompiler) // place routes in src/main/resources, or remove if using SIRD/RoutingDsl
.settings(
scalaVersion := "2.12.18",
scalaVersion := "2.12.19",
libraryDependencies ++= Seq(
guice, // remove if not using Play's Guice loader
akkaHttpServer, // or use nettyServer for Netty
Expand Down
4 changes: 2 additions & 2 deletions documentation/manual/releases/release27/Highlights27.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can select which version of Scala you would like to use by setting the `scal
For Scala 2.12:

```scala
scalaVersion := "2.12.18"
scalaVersion := "2.12.19"
```

For Scala 2.11:
Expand All @@ -25,7 +25,7 @@ scalaVersion := "2.11.12"
For Scala 2.13:

```scala
scalaVersion := "2.13.12"
scalaVersion := "2.13.13"
```

## Lifecycle managed by Akka's Coordinated Shutdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ Play 2.8 support Scala 2.12 and 2.13, but not 2.11, which has reached its end of
To set the Scala version in sbt, simply set the `scalaVersion` key, for example:

```scala
scalaVersion := "2.13.12"
scalaVersion := "2.13.13"
```

If you have a single project build, then this setting can just be placed on its own line in `build.sbt`. However, if you have a multi-project build, then the scala version setting must be set on each project. Typically, in a multi-project build, you will have some common settings shared by every project, this is the best place to put the setting, for example:

```scala
def commonSettings = Seq(
scalaVersion := "2.13.12"
scalaVersion := "2.13.13"
)

val projectA = (project in file("projectA"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ Play 2.9 supports Scala 2.13 and Scala 3.3, but not 2.12 anymore. Scala 3 requir
To set the Scala version in sbt, simply set the `scalaVersion` key, for example:

```scala
scalaVersion := "2.13.12"
scalaVersion := "2.13.13"
```

Play 2.9 also supports Scala 3:

```scala
scalaVersion := "3.3.1"
scalaVersion := "3.3.2"
```

> It's important to emphasize that Play exclusively supports [Scala LTS (Long-Term Support)](https://www.scala-lang.org/blog/2022/08/17/long-term-compatibility-plans.html) versions. As a result, any Scala release between Scala 3.3 LTS and the subsequent LTS version will not be officially supported by Play. However, it might still be feasible to use Play with such Scala versions.
Expand All @@ -77,7 +77,7 @@ If you have a single project build, then this setting can just be placed on its

```scala
def commonSettings = Seq(
scalaVersion := "2.13.12"
scalaVersion := "2.13.13"
)

val projectA = (project in file("projectA"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If you use `groupID %% artifactID % revision` rather than `groupID % artifactID

@[explicit-scala-version-dep](code/dependencies.sbt)

Assuming the `scalaVersion` for your build is `2.13.12`, the following is identical (note the double `%%` after `"org.scala-tools"`):
Assuming the `scalaVersion` for your build is `2.13.13`, the following is identical (note the double `%%` after `"org.scala-tools"`):

@[auto-scala-version-dep](code/dependencies.sbt)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ class ScalaWebSockets extends PlaySpecification {
* The default await timeout. Override this to change it.
*/
import scala.concurrent.duration._
implicit override def defaultAwaitTimeout = 2.seconds

import akka.util.Timeout
implicit override def defaultAwaitTimeout: Timeout = 2.seconds
}

object Controller1 {
Expand Down
6 changes: 3 additions & 3 deletions project/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*/

object ScalaVersions {
val scala212 = "2.12.18"
val scala213 = "2.13.12"
val scala3 = "3.3.1"
val scala212 = "2.12.19"
val scala213 = "2.13.13"
val scala3 = "3.3.2"
}

object SbtVersions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ object CSRF {
* The CSRF module.
*/
class CSRFModule extends Module {
def bindings(environment: Environment, configuration: Configuration) =
def bindings(environment: Environment, configuration: Configuration): scala.collection.Seq[Binding[_]] =
Seq(
bind[play.libs.crypto.CSRFTokenSigner].to(classOf[play.libs.crypto.DefaultCSRFTokenSigner]),
bind[CSRFTokenSigner].toProvider[CSRFTokenSignerProvider],
Expand Down

0 comments on commit eaa143f

Please sign in to comment.