scalaakkagrpcpekko

Akka to Pekko Migration and Grpc


Heeey all,

I'm doing a Akka to Pekko migration of a pet project (I'm learning scala atm). So far everything went smooth but there is one thing that I can't get fixed and the grpc plugin.

In my build.sbt I've got the following:

ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "3.3.1"

lazy val root = (project in file("."))
  .settings(
    name := "IracingSetups",
  )

...
val pekkoVersion = "1.0.2"
...
("org.apache.pekko"  %% "pekko-actor" % pekkoVersion),
("org.apache.pekko" %% "pekko-actor-typed" % pekkoVersion),
("org.apache.pekko" %% "pekko-actor-testkit-typed" % pekkoVersion % "test"),
("org.apache.pekko"            %% "pekko-grpc-runtime"           % pekkoVersion),
...
enablePlugins(PekkoGrpcPlugin)

and in my plugins.sbt I have:

resolvers += "Akka library repository".at("https://repo.akka.io/maven")

addSbtPlugin("io.spray"                % "sbt-revolver"           % "0.9.1")
addSbtPlugin("org.apache.pekko"        % "pekko-grpc-sbt-plugin"  % "1.0.2")

Everything seems download ok but when I run: compile I get:

IJ]compile
[info] Compiling 1 protobuf files to /Users/leon.weemen/Documents/Personal/IracingSetups/target/scala-3.3.1/pekko-grpc/main
[info] Generating Apache Pekko gRPC service interface for com.weemen.iracingsetups.IracingService
[info] Generating Apache Pekko gRPC client for com.weemen.iracingsetups.IracingService
[info] Generating Apache Pekko gRPC service handler for com.weemen.iracingsetups.IracingService
[info] compiling 13 Scala sources to /Users/leon.weemen/Documents/Personal/IracingSetups/target/scala-3.3.1/classes ...
[error] -- [E006] Not Found Error: /Users/leon.weemen/Documents/Personal/IracingSetups/target/scala-3.3.1/pekko-grpc/main/com/weemen/iracingsetups/DriveMessage.scala:167:28 
[error] 167 |object DriveMessage extends scalapb.GeneratedMessageCompanion[com.weemen.iracingsetups.DriveMessage] {
[error]     |                            ^^^^^^^
[error]     |                            Not found: scalapb
[error]     |
[error]     | longer explanation available when compiling with `-explain`

After that I followed the installation instructions and added the following to the build.sbt

"com.thesamet.scalapb" %% "compilerplugin" % "0.11.11"

and I added the following plugin:

addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")

of course I did set the default compiler options by doing:

Compile / PB.targets := Seq(
  scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
)

This improved my situation however still some class that were autogenerated before are not there:

[IJ]compile
[info] Compiling 1 protobuf files to /Users/leon.weemen/Documents/Personal/IracingSetups/target/scala-3.3.1/src_managed/main/scalapb
[info] compiling 11 Scala sources to /Users/leon.weemen/Documents/Personal/IracingSetups/target/scala-3.3.1/classes ...
[error] -- [E006] Not Found Error: /Users/leon.weemen/Documents/Personal/IracingSetups/src/main/scala/com/weemen/iracingsetups/IracingSetupsGrpcImpl.scala:11:75 
[error] 11 |class IracingSetupsGrpcImpl(using val typedSystem: ActorSystem[?]) extends IracingService {
[error]    |                                                                           ^^^^^^^^^^^^^^
[error]    |                                          Not found: type IracingService

Did I miss something super obvious here or has things been changed in Pekko that used to work with Akka. addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "2.1.6") always used to work out of the box me.

PS: I'm a total n00b with Scala. I'm also 100% sure if I have gave you enough information to work with


Solution

  • I totally forgot about this question but I found the culprit. I copied a lot of things from a different project and one of the things that I missed was a cross compile setting. I',m fully on Scala3 after I removed the cross compile setting my problems disappeared as snow in front of the sun.