I’m working on a Scala project that currently implements a simple REST API. I’m trying to add a new gRPC service to this project. However, I’m encountering an issue during compilation.
Issue:
When I run sbt compile, it generates an fs2-grpcs folder, but this folder is empty. The expected proto-generated classes are missing.
My build.sbt file
val scala3Version = "3.3.1"
val http4sVersion = "0.23.23"
val weaverVersion = "0.8.3"
ThisBuild / scalaVersion := "3.3.1"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalacOptions ++= Seq("-Yretain-trees")
// Add global resolvers
ThisBuild / resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
)
lazy val protobuf =
project
.in(file("protobuf"))
.settings(
name := "protobuf",
scalaVersion := scala3Version
)
.enablePlugins(Fs2Grpc)
lazy val root = project
.in(file("."))
.settings(
name := "scan-meet",
// Library dependencies
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % "2.1.5",
"dev.zio" %% "zio-http" % "3.0.0-RC2",
"dev.zio" %% "zio-streams" % "2.1.5",
...
"io.grpc" % "grpc-netty-shaded" % scalapb.compiler.Version.grpcJavaVersion,
"org.http4s" %% "http4s-ember-server" % "0.23.27",
"org.http4s" %% "http4s-dsl" % "0.23.27",
"org.http4s" %% "http4s-circe" % "0.23.27",
"com.disneystreaming" %% "weaver-cats" % "0.8.4" % Test,
"io.grpc" % "grpc-netty" % scalapb.compiler.Version.grpcJavaVersion,
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion
),
testFrameworks += new TestFramework("weaver.framework.CatsEffect")
)
.dependsOn(protobuf)
My hello.proto file
syntax = "proto3";
package com.example.protos;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloReply {
string message = 1;
}
My project structure project structure
Steps taken:
Added necessary gRPC dependencies to the project
Created a .proto file for the new gRPC service
Ran sbt compile
I am not getting any erros, I get the target folder generated with emoty fs2-grpc folder, I am expecting to get generated classes there
Ayadi Tahar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1