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

Draft
wants to merge 2 commits into
base: 0.11.x
Choose a base branch
from

Conversation

mkurz
Copy link
Member

@mkurz mkurz commented Dec 21, 2023

A bit more tricky than on main branch because following dependencies do not provide Scala 3 artifacts:

com.lightbend.akka.grpc:akka-grpc-codegen:2.1.5
com.lightbend.akka.grpc:akka-grpc-runtime:2.1.5

com.typesafe.akka:akka-http-spray-json:10.2.10
com.typesafe.akka:akka-http2-support:10.2.10
com.typesafe.akka:akka-http:10.2.10

@mkurz mkurz marked this pull request as draft December 22, 2023 09:32
@mkurz
Copy link
Member Author

mkurz commented Dec 22, 2023

Seems we ran into a show stopper here when using the outdated akka-grpc 2.1.x dependencies:

[error] -- Error: /home/runner/work/play-grpc/play-grpc/play-testdata/target/scala-3.3.1/src_managed/main/example/myapp/helloworld/grpc/helloworld/GreeterServiceMarshallers.scala:23:15 
[error] 23 |  implicit val HelloRequestSerializer = example.myapp.helloworld.grpc.helloworld.GreeterService.Serializers.HelloRequestSerializer
[error]    |               ^
[error]    |               type of implicit definition needs to be given explicitly
[error] -- Error: /home/runner/work/play-grpc/play-grpc/play-testdata/target/scala-3.3.1/src_managed/main/example/myapp/helloworld/grpc/helloworld/GreeterServiceMarshallers.scala:25:15 
[error] 25 |  implicit val HelloReplySerializer = example.myapp.helloworld.grpc.helloworld.GreeterService.Serializers.HelloReplySerializer
[error]    |               ^
[error]    |               type of implicit definition needs to be given explicitly
[warn] 6 warnings found
[error] two errors found
...
[error] -- Error: /home/runner/work/play-grpc/play-grpc/play-interop-test-scala/target/scala-3.3.1/src_managed/main/example/myapp/helloworld/grpc/helloworld/GreeterServiceMarshallers.scala:23:15 
[error] 23 |  implicit val HelloRequestSerializer = example.myapp.helloworld.grpc.helloworld.GreeterService.Serializers.HelloRequestSerializer
[error]    |               ^
[error]    |               type of implicit definition needs to be given explicitly
[error] -- Error: /home/runner/work/play-grpc/play-grpc/play-interop-test-scala/target/scala-3.3.1/src_managed/main/example/myapp/helloworld/grpc/helloworld/GreeterServiceMarshallers.scala:25:15 
[error] 25 |  implicit val HelloReplySerializer = example.myapp.helloworld.grpc.helloworld.GreeterService.Serializers.HelloReplySerializer
[error]    |               ^
[error]    |               type of implicit definition needs to be given explicitly
[warn] 5 warnings found
[error] two errors found

The generated code does not explicitly define the type of the implicits, which is needed for Scala 3. This was fixed in pekko-grpc already but akka-grpc only fixed that in version 2.3.0 which already is licenced under the BSL.

Conclusion: With the last Open Source version of akka-grpc, which is 2.1.x, it is impossible to provide Scala 3 artifacts for play-grpc. So I will put this on hold for now. We could in theory pull in the BSL licenced akka-grpc artifacts which already come with native Scala 3 support and everything should work, including the ALPN problem, just to make tests pass. We could mark them as provided for the Scala 3 build, so if someone using the akka stack under the BSL licences could in theory also make use of play-grpc by adding the deps manually.
If you read this and are interested in that, please comment here and let us now.

@mkurz mkurz changed the title [0.11.x] Activate Scala 3 [0.11.x] Activate Scala 3 when using the Akka stack Dec 22, 2023
@felixbr
Copy link

felixbr commented Feb 6, 2024

If you read this and are interested in that, please comment here and let us now.

Hi, I am interested in that. My company uses Akka in many projects and we have acquired the BSL last year and don't intend to migrate to Pekko in the near future*. In particular play-grpc is currently the last blocker for switching to Scala 3 in one of our projects.

As I understand 0.12.x and beyond will use Pekko and 0.11.x will be the version/branch for Akka support. In this scenario your proposal of pulling in akka-grpc 2.3.x as provided makes sense, as people without a BSL will want to use 0.12.x anyway.

If I can assist in any way, let me know 🙂

~ Felix

*I'm not necessarily against migrating to Pekko but these migrations tend to be a massive headache if you have a big existing codebase.

@mkurz
Copy link
Member Author

mkurz commented Mar 14, 2024

@felixbr Are you still interested in this PR?

@felixbr
Copy link

felixbr commented Mar 14, 2024

@mkurz I'm still interested, yes

@mkurz
Copy link
Member Author

mkurz commented Mar 15, 2024

@felixbr I maybe take a look on this monday.

@mkurz
Copy link
Member Author

mkurz commented May 25, 2024

@felixbr @muuki88 if you are still interested, I released 0.11.1-M1 which you can give a try. It provides Scala 3 artifacts, built with newer akka libraries that are BSL licensed. However, these dependencies marked as provided so you would have to pull them in yourself, because we do not ship any bsl dependencies. Making this work is an exception now, because there is no other way to provide Scala 3 artifacts for play-grpc using Play 2.9. I was interested myself how to make this work so I gave it a try.

That means in plugins.sbt you would have to:

libraryDependencies += "com.typesafe.play" %% "play-grpc-generators" % "0.11.1-M1"
libraryDependencies += "com.lightbend.akka.grpc" %% "akka-grpc-codegen" % "2.3.4" // or newer

and in build.sbt:

libraryDependencies += "com.typesafe.play" %% "play-grpc-runtime" % "0.11.1-M1"
libraryDependencies += "com.typesafe.akka" %% "akka-discovery" % "2.7.0" // or newer
libraryDependencies += "com.typesafe.akka" %% ... // see below

and all other provided dependencies listed in the pom here: view-source:https://repo1.maven.org/maven2/com/typesafe/play/play-grpc-runtime_3/0.11.1-M1/play-grpc-runtime_3-0.11.1-M1.pom

@felixbr
Copy link

felixbr commented May 27, 2024

Thank you for that effort!

I'll try and make time in the next two weeks to give our Scala 3 migration another push with those artifacts and report back.

If the migration works out well, we might tackle Pekko next. We do have a license for Akka but if using it puts unnecessary strain on open-source maintainers like you in the long run, we should do our part to alleviate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants