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

Drop Scala 2.12 and sbt 1.3 (and 0.13.x leftovers) #10956

Merged
merged 8 commits into from Aug 30, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 0 additions & 59 deletions .travis.yml
Expand Up @@ -16,9 +16,7 @@ env:
global:
- secure: "NS2hMbBcmi6EF4QxtcNs4A2ZuNmIdLYQRJUWWejgnD4YtcsmoVjxrHRedqrnDdui4DyvaxWhg/3Uds23jEKTSbbh3ZphLO77BVgM2nUGUvVoa4i6qGF2eZFlIhq2G1gM700GPV7X4KmyjYi2HtH8CWBTkqP3g0An63mCZw/Gnlk="
# These are the versions used for (scripted) tests. The versions Play is build with however are defined in interplay.
- SCRIPTED_SBT_1_3: "1.3.13"
- SCRIPTED_SBT_1_5: "1.5.5"
- TEST_SCALA_2_12: "2.12.14"
- TEST_SCALA_2_13: "2.13.6"
jobs:
- TRAVIS_JDK=11
Expand All @@ -36,8 +34,6 @@ install: jabba install $(jabba ls-remote "adopt@~1.$TRAVIS_JDK.0-0" --latest=pat
stages:
- validations
- test
- test-sbt-1.3.x
- cron-test-sbt-1.3.x
- cron-test-sbt-1.5.x
- java8

Expand Down Expand Up @@ -68,66 +64,11 @@ jobs:
- stage: test
script: scripts/it-test $TEST_SCALA_2_13
name: "Run it tests for Scala 2.13"
- script: scripts/it-test $TEST_SCALA_2_12
name: "Run it tests for Scala 2.12"
- script: scripts/test $TEST_SCALA_2_13
name: "Run tests for Scala 2.13"
- script: scripts/test $TEST_SCALA_2_12
name: "Run tests for Scala 2.12"
- script: scripts/test-docs $TEST_SCALA_2_13
name: "Run documentation tests 2.13"
- script: scripts/test-docs $TEST_SCALA_2_12
name: "Run documentation tests 2.12"

- stage: test-sbt-1.3.x
mkurz marked this conversation as resolved.
Show resolved Hide resolved
name: "Run scripted tests (a) for sbt 1.3.x and Scala 2.12.x"
script: scripts/test-scripted $SCRIPTED_SBT_1_3 $TEST_SCALA_2_12 'play-sbt-plugin/*1of3'
workspaces:
use: published-local
- name: "Run scripted tests (b) for sbt 1.3.x and Scala 2.12.x"
script: scripts/test-scripted $SCRIPTED_SBT_1_3 $TEST_SCALA_2_12 'play-sbt-plugin/*2of3'
workspaces:
use: published-local
- name: "Run scripted tests (c) for sbt 1.3.x and Scala 2.12.x"
script: scripts/test-scripted $SCRIPTED_SBT_1_3 $TEST_SCALA_2_12 'play-sbt-plugin/*3of3'
workspaces:
use: published-local

# Test against Java 8, but only for Scala 2.12
- stage: java8
script: scripts/test $TEST_SCALA_2_12
env: TRAVIS_JDK=8
name: "Run tests for Scala 2.12 and Java 8"
- script: scripts/it-test $TEST_SCALA_2_12
env: TRAVIS_JDK=8
name: "Run it tests for Scala 2.12 and Java 8"
- script: scripts/test-docs $TEST_SCALA_2_12
env: TRAVIS_JDK=8
name: "Run documentation tests for Scala 2.12 and Java 8"
- name: "Run scripted tests (a) for sbt 1.3.x and Scala 2.12.x and Java 8"
script: scripts/test-scripted $SCRIPTED_SBT_1_3 $TEST_SCALA_2_12 'play-sbt-plugin/*1of3'
env: TRAVIS_JDK=8
workspaces:
use: published-local-jdk8
- name: "Run scripted tests (b) for sbt 1.3.x and Scala 2.12.x and Java 8"
script: scripts/test-scripted $SCRIPTED_SBT_1_3 $TEST_SCALA_2_12 'play-sbt-plugin/*2of3'
env: TRAVIS_JDK=8
workspaces:
use: published-local-jdk8
- name: "Run scripted tests (c) for sbt 1.3.x and Scala 2.12.x and Java 8"
script: scripts/test-scripted $SCRIPTED_SBT_1_3 $TEST_SCALA_2_12 'play-sbt-plugin/*3of3'
env: TRAVIS_JDK=8
workspaces:
use: published-local-jdk8

# Test against sbt 1.3.x and Scala 2.13.x, but only for cron builds
# (sbt 1.3.x / Scala 2.12.x was tested above already)
- stage: cron-test-sbt-1.3.x
name: "Run tests for sbt 1.3.x and Scala 2.13.x"
script: scripts/test-scripted $SCRIPTED_SBT_1_3 $TEST_SCALA_2_13
if: type = cron
workspaces:
use: published-local
# Test against sbt 1.5.x, but only for cron builds
- stage: cron-test-sbt-1.5.x
name: "Run tests for 1.5.x and Scala 2.13.x"
Expand Down
7 changes: 0 additions & 7 deletions build.sbt
Expand Up @@ -74,13 +74,6 @@ lazy val PlayProject = PlayCrossBuiltProject("Play", "core/play")
.settings(
libraryDependencies ++= runtime(scalaVersion.value) ++ scalacheckDependencies ++ cookieEncodingDependencies :+
jimfs % Test,
(Compile / unmanagedSourceDirectories) ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13) | (3, _)) => (Compile / sourceDirectory).value / s"java-scala-2.13+" :: Nil
case Some((2, v)) if v <= 12 => (Compile / sourceDirectory).value / s"java-scala-2.13-" :: Nil
case _ => Nil
}
},
(Compile / sourceGenerators) += Def
.task(
PlayVersion(
Expand Down
41 changes: 0 additions & 41 deletions core/play/src/main/java-scala-2.13+/play/libs/CrossScala.java

This file was deleted.

41 changes: 0 additions & 41 deletions core/play/src/main/java-scala-2.13-/play/libs/CrossScala.java

This file was deleted.

36 changes: 35 additions & 1 deletion core/play/src/main/java/play/libs/Scala.java
Expand Up @@ -16,7 +16,41 @@
import java.util.function.Function;

/** Class that contains useful java &lt;-&gt; scala conversion helpers. */
public class Scala extends CrossScala {
public class Scala {

/**
* Converts a Java List to Scala Seq.
*
* @param list the java list.
* @return the converted Seq.
* @param <T> the element type.
*/
public static <T> scala.collection.immutable.Seq<T> toSeq(java.util.List<T> list) {
return scala.collection.JavaConverters.asScalaBufferConverter(list).asScala().toList();
}

/**
* Converts a Java Array to Scala Seq.
*
* @param array the java array.
* @return the converted Seq.
* @param <T> the element type.
*/
public static <T> scala.collection.immutable.Seq<T> toSeq(T[] array) {
return toSeq(java.util.Arrays.asList(array));
}

/**
* Converts a Java varargs to Scala varargs.
*
* @param array the java array.
* @return the Scala varargs
* @param <T> the element type.
*/
@SafeVarargs
public static <T> scala.collection.immutable.Seq<T> varargs(T... array) {
return toSeq(array);
}

/**
* Wraps a Scala Option, handling None as null.
Expand Down
6 changes: 1 addition & 5 deletions core/play/src/test/scala/play/api/mvc/ResultsSpec.scala
Expand Up @@ -86,11 +86,7 @@ class ResultsSpec extends Specification {

headers.size must_== 2
headers must havePair("Set-Cookie" -> "yes")
// In Scala 2.12 (and earlier) the second version of the key ("X-Yop") is in the map
// As of Scala 2.13 the original version of the key ("X-YOP") is in the map
// from fixing bug https://github.com/scala/bug/issues/11514
(headers must not).havePair("X-YOP" -> "1").and(headers must not).havePair("X-Yop" -> "1")
(headers must havePair("X-Yop" -> "2")).or(headers must havePair("X-YOP" -> "2"))
headers must havePair("X-YOP" -> "2")
}

"support date headers manipulation" in {
Expand Down
8 changes: 0 additions & 8 deletions dev-mode/sbt-plugin/src/main/scala/play/sbt/run/PlayRun.scala
Expand Up @@ -53,14 +53,6 @@ object PlayRun {
val playDefaultRunTask =
playRunTask(playRunHooks, playDependencyClasspath, playReloaderClasspath, playAssetsClassLoader)

/**
* This method is public API, used by sbt-echo, which is used by Activator:
*
* https://github.com/typesafehub/sbt-echo/blob/v0.1.3/play/src/main/scala-sbt-0.13/com/typesafe/sbt/echo/EchoPlaySpecific.scala#L20
*
* Do not change its signature without first consulting the Activator team. Do not change its signature in a minor
* release.
*/
mkurz marked this conversation as resolved.
Show resolved Hide resolved
def playRunTask(
runHooks: TaskKey[Seq[PlayRunHook]],
dependencyClasspath: TaskKey[Classpath],
Expand Down
Expand Up @@ -5,7 +5,6 @@ lazy val root = (project in file("."))
.enablePlugins(PlayJava)

libraryDependencies ++= Seq(guice, specs2 % Test)
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.3.2" // can be removed when dropping Scala 2.12
mkurz marked this conversation as resolved.
Show resolved Hide resolved

scalaVersion := sys.props("scala.version")
updateOptions := updateOptions.value.withLatestSnapshots(false)
Expand Down
Expand Up @@ -5,7 +5,6 @@ lazy val root = (project in file("."))
.enablePlugins(PlayScala)

libraryDependencies ++= Seq(guice, specs2 % Test)
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.3.2" // can be removed when dropping Scala 2.12

scalaVersion := sys.props("scala.version")
updateOptions := updateOptions.value.withLatestSnapshots(false)
Expand Down
Expand Up @@ -5,7 +5,6 @@ lazy val root = (project in file("."))
.enablePlugins(PlayScala)

libraryDependencies ++= Seq(guice, specs2 % Test)
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.3.2" // can be removed when dropping Scala 2.12

scalaVersion := sys.props("scala.version")
updateOptions := updateOptions.value.withLatestSnapshots(false)
Expand Down
Expand Up @@ -5,7 +5,6 @@ lazy val root = (project in file("."))
.enablePlugins(PlayScala)

libraryDependencies ++= Seq(guice, specs2 % Test)
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.3.2" // can be removed when dropping Scala 2.12

scalaVersion := sys.props("scala.version")
updateOptions := updateOptions.value.withLatestSnapshots(false)
Expand Down
2 changes: 1 addition & 1 deletion documentation/build.sbt
Expand Up @@ -75,7 +75,7 @@ lazy val main = Project("Play-Documentation", file("."))
unmanagedResourceDirectories in Test ++= (baseDirectory.value / "manual" / "detailedTopics" ** "code").get,
// Don't include sbt files in the resources
excludeFilter in (Test, unmanagedResources) := (excludeFilter in (Test, unmanagedResources)).value || "*.sbt",
crossScalaVersions := Seq("2.13.6", "2.12.14"),
crossScalaVersions := Seq("2.13.6"),
scalaVersion := "2.13.6",
fork in Test := true,
javaOptions in Test ++= Seq("-Xmx512m", "-Xms128m"),
Expand Down
2 changes: 1 addition & 1 deletion documentation/manual/gettingStarted/PlayConsole.md
Expand Up @@ -38,7 +38,7 @@ my-first-app $ sbt
You will see something like:

```
[info] Loading global plugins from /Users/play-developer/.sbt/0.13/plugins
[info] Loading global plugins from /Users/play-developer/.sbt/1.0/plugins
[info] Loading project definition from /Users/play-developer/my-first-app/project
[info] Updating {file:/Users/play-developer/my-first-app/project/}my-first-app-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
Expand Down
2 changes: 1 addition & 1 deletion documentation/manual/hacking/Translations.md
Expand Up @@ -39,7 +39,7 @@ translation-project
`build.properties` should contain the sbt version, ie:

```
sbt.version=0.13.16
sbt.version=1.5.5
```

`plugins.sbt` should include the Play docs sbt plugin, ie:
Expand Down
36 changes: 33 additions & 3 deletions documentation/manual/releases/release29/migration29/Migration29.md
Expand Up @@ -20,13 +20,13 @@ Where the "x" in `2.9.x` is the minor version of Play you want to use, for insta

### sbt upgrade

Play 2.9 only supports sbt 1. To update, change your `project/build.properties` so that it reads:
Play 2.9 only supports sbt 1.5. To update, change your `project/build.properties` so that it reads:

```properties
sbt.version=1.3.10
sbt.version=1.5.5
```

At the time of this writing `1.3.10` is the latest version in the sbt 1.x family, you may be able to use newer versions too. Check the release notes for both Play's minor version [releases](https://github.com/playframework/playframework/releases) and sbt's [releases](https://github.com/sbt/sbt/releases) for details.
At the time of this writing `1.5.5` is the latest version in the sbt 1.x family, you may be able to use newer versions too. Check the release notes for both Play's minor version [releases](https://github.com/playframework/playframework/releases) and sbt's [releases](https://github.com/sbt/sbt/releases) for details.

### Minimum required Java version

Expand All @@ -37,6 +37,36 @@ In case you passed a `-javaagent:jetty-alpn-agent-*.jar` flag to your Play appli

Play 2.9 contains multiple API changes. As usual, we follow our policy of deprecating existing APIs before removing them. This section details these changes.

### Scala 2.12 support discontinued

Play 2.9 supports Scala 2.13, but not 2.12 anymore.

### Setting `scalaVersion` in your project

**Both Scala and Java users** must configure sbt to use Scala 2.13. Even if you have no Scala code in your project, Play itself uses Scala and must be configured to use the right Scala libraries.

To set the Scala version in sbt, simply set the `scalaVersion` key, for example:

```scala
scalaVersion := "2.13.6"
```

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.6"
)

val projectA = (project in file("projectA"))
.enablePlugins(PlayJava)
.settings(commonSettings)

val projectB = (project in file("projectB"))
.enablePlugins(PlayJava)
.settings(commonSettings)
```

mkurz marked this conversation as resolved.
Show resolved Hide resolved
### Deprecated APIs were removed

Many APIs that were deprecated in earlier versions were removed in Play 2.9. If you are still using them we recommend migrating to the new APIs before upgrading to Play 2.9. Check the Javadocs and Scaladocs for migration notes. See also the [[migration guide for Play 2.8|Migration28]] for more information.
Expand Down
Expand Up @@ -26,7 +26,7 @@ And will see something like:

```bash
$ sbt
[info] Loading global plugins from /Users/play-developer/.sbt/0.13/plugins
[info] Loading global plugins from /Users/play-developer/.sbt/1.0/plugins
[info] Loading project definition from /Users/play-developer/my-first-app/project
[info] Set current project to my-first-app (in build file:/Users/play-developer/my-first-app/)
[my-first-app] $ dist
Expand Down Expand Up @@ -193,7 +193,7 @@ And you will see something like this:

```bash
$ sbt
[info] Loading global plugins from /Users/play-developer/.sbt/0.13/plugins
[info] Loading global plugins from /Users/play-developer/.sbt/1.0/plugins
[info] Loading project definition from /Users/play-developer/my-first-app/project
[info] Set current project to my-first-app (in build file:/Users/play-developer/my-first-app/)
[my-first-app] $ stage
Expand Down
Expand Up @@ -36,7 +36,7 @@ The default body parser produces a body of type [`AnyContent`](api/scala/play/ap
The following is a mapping of types supported by the default body parser:

- **text/plain**: `String`, accessible via `asText`.
- **application/json**: [`JsValue`](https://static.javadoc.io/com.typesafe.play/play-json_2.12/2.6.9/play/api/libs/json/JsValue.html), accessible via `asJson`.
- **application/json**: [`JsValue`](https://static.javadoc.io/com.typesafe.play/play-json_2.13/2.6.9/play/api/libs/json/JsValue.html), accessible via `asJson`.
- **application/xml**, **text/xml** or **application/XXX+xml**: `scala.xml.NodeSeq`, accessible via `asXml`.
- **application/x-www-form-urlencoded**: `Map[String, Seq[String]]`, accessible via `asFormUrlEncoded`.
- **multipart/form-data**: [`MultipartFormData`](api/scala/play/api/mvc/MultipartFormData.html), accessible via `asMultipartFormData`.
Expand Down