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

[0.11.x] Activate Scala 3 when using the Akka stack #498

Closed
wants to merge 2 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 @@ -39,7 +39,7 @@ jobs:
uses: playframework/.github/.github/workflows/cmd.yml@v3
with:
java: 17, 11
scala: 2.13.x
scala: 3.x, 2.13.x
cmd: sbt ++$MATRIX_SCALA test

finish:
Expand Down
20 changes: 18 additions & 2 deletions project/CommonPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ package build.play.grpc
import sbt._
import sbt.Keys._

import Dependencies.Versions.scala212
import Dependencies.Versions.scala213
import Dependencies.Versions.scala3

// WORKAROUND https://github.com/sbt/sbt/issues/2899
object CommonPlugin extends AutoPlugin {
override def trigger = allRequirements

private val akkaDeps =
Seq("akka-actor", "akka-actor-typed", "akka-slf4j", "akka-serialization-jackson", "akka-stream", "akka-discovery")
private val scala2Deps = Map(
"com.typesafe.akka" -> ("2.6.21", akkaDeps),
"com.typesafe" -> ("0.6.1", Seq("ssl-config-core")),
"com.fasterxml.jackson.module" -> ("2.14.3", Seq("jackson-module-scala")),
"org.scala-lang.modules" -> ("xxx", Seq("scala-parser-combinators")),
)

override def projectSettings = Seq(
scalacOptions ++= {
if (scalaVersionNumber.value.matchesSemVer(SemanticSelector("<=2.12")))
Expand All @@ -20,8 +29,15 @@ object CommonPlugin extends AutoPlugin {
doc / javacOptions --= Seq("-Xlint:unchecked", "-Xlint:deprecation"),
Test / javaOptions ++= Seq("--add-exports=java.base/sun.security.x509=ALL-UNNAMED"),
Test / fork := true,
crossScalaVersions := Seq(scala213),
crossScalaVersions := Seq(scala213, scala3),
scalaVersion := scala213,
// Work around needed because akka-http 10.2.x is not published for Scala 3
excludeDependencies ++=
(if (scalaBinaryVersion.value == "3") {
scala2Deps.flatMap(e => e._2._2.map(_ + "_3").map(ExclusionRule(e._1, _))).toSeq
} else {
Seq.empty
}),
)

val scalaVersionNumber = Def.setting(VersionNumber(scalaVersion.value))
Expand Down
19 changes: 13 additions & 6 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object Dependencies {
object Versions {
val scala212 = "2.12.19"
val scala213 = "2.13.14"
val scala3 = "3.3.3"

// Don't use AkkaGrpcBuildInfo.akkaHttpVersion or AkkaGrpcBuildInfo.akkaVersion and prioritize
// aligning with versions transitively brought in via Play.
Expand Down Expand Up @@ -39,12 +40,18 @@ object Dependencies {
val akkaPersistenceQuery = "com.typesafe.akka" %% "akka-persistence-query" % Versions.akka
val akkaSerializationJackson = "com.typesafe.akka" %% "akka-serialization-jackson" % Versions.akka

val akkaHttp = "com.typesafe.akka" %% "akka-http" % Versions.akkaHttp
val akkaHttpSprayJson = "com.typesafe.akka" %% "akka-http-spray-json" % Versions.akkaHttp
val akkaHttp2Support = "com.typesafe.akka" %% "akka-http2-support" % Versions.akkaHttp

val akkaGrpcCodegen = "com.lightbend.akka.grpc" %% "akka-grpc-codegen" % Versions.akkaGrpc // Apache V2
val akkaGrpcRuntime = "com.lightbend.akka.grpc" %% "akka-grpc-runtime" % Versions.akkaGrpc // Apache V2
val akkaHttp = ("com.typesafe.akka" %% "akka-http" % Versions.akkaHttp).cross(CrossVersion.for3Use2_13)
val akkaHttpSprayJson =
("com.typesafe.akka" %% "akka-http-spray-json" % Versions.akkaHttp).cross(CrossVersion.for3Use2_13)
val akkaHttp2Support =
("com.typesafe.akka" %% "akka-http2-support" % Versions.akkaHttp).cross(CrossVersion.for3Use2_13)

val akkaGrpcCodegen = ("com.lightbend.akka.grpc" %% "akka-grpc-codegen" % Versions.akkaGrpc).cross(
CrossVersion.for3Use2_13
) // Apache V2
val akkaGrpcRuntime = ("com.lightbend.akka.grpc" %% "akka-grpc-runtime" % Versions.akkaGrpc).cross(
CrossVersion.for3Use2_13
) // Apache V2

val play = ("com.typesafe.play" %% "play" % Versions.play)
.exclude("javax.activation", "javax.activation-api") // Apache V2 (exclusion is "either GPL or CDDL")
Expand Down
Loading