Skip to content
This repository was archived by the owner on May 26, 2025. It is now read-only.
Open
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
15 changes: 9 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scalapb.compiler.Version.{grpcJavaVersion, scalapbVersion, protobufVersion}
import scalapb.compiler.Version.{scalapbVersion, protobufVersion}

val unusedWarnings = (
"-Ywarn-unused" ::
Expand All @@ -9,20 +9,20 @@ lazy val root = project.in(file(".")).aggregate(
grpcJavaSample, grpcScalaSample
)

def Scala212 = "2.12.16"
def Scala3 = "3.7.0"

val commonSettings: Seq[Def.Setting[_]] = Seq[Def.Setting[_]](
Test / fork := true,
scalaVersion := Scala212,
crossScalaVersions := List(Scala212), // TODO add Scala 2.13
scalaVersion := Scala3,
crossScalaVersions := List(Scala3),
libraryDependencies += "io.grpc" % "grpc-netty" % grpcJavaVersion,
libraryDependencies += "com.thesamet.scalapb" %% "scalapb-runtime" % scalapbVersion % "protobuf"
)

lazy val grpcScalaSample = project.in(file("grpc-scala")).settings(
commonSettings,
libraryDependencies += "com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapbVersion,
Compile / PB.targets := Seq(scalapb.gen() -> (Compile / sourceManaged).value),
Compile / PB.targets := Seq(scalapb.gen(scala3Sources = true) -> (Compile / sourceManaged).value),
Compile / unmanagedResourceDirectories += (LocalRootProject / baseDirectory).value / "grpc-java/examples/src/main/resources",
Compile / PB.protoSources += (LocalRootProject / baseDirectory).value / "grpc-java/examples/src/main/proto",
scalacOptions ++= (
Expand Down Expand Up @@ -58,12 +58,15 @@ lazy val grpcExeUrl =

val grpcExePath = SettingKey[xsbti.api.Lazy[File]]("grpcExePath")

val grpcJavaVersion = "1.72.0"

lazy val grpcJavaSample = project.in(file("grpc-java/examples")).settings(
commonSettings,
Compile / PB.targets := Seq(PB.gens.java(protobufVersion) -> (Compile / sourceManaged).value),
Compile / PB.protocOptions ++= Seq(
s"--plugin=protoc-gen-java_rpc=${grpcExePath.value.get}",
s"--java_rpc_out=${((Compile / sourceManaged).value).getAbsolutePath}"
s"--java_rpc_out=${((Compile / sourceManaged).value).getAbsolutePath}",
s"--java_rpc_opt=@generated=omit"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this we get:

[error] /Users/jason/src/grpc-scala-sample/grpc-java/examples/target/scala-3.7.0/src_managed/main/io/grpc/examples/helloworld/GreeterGrpc.java:10:18: cannot find symbol
[error]   symbol:   class Generated
[error]   location: package javax.annotation
[error] javax.annotation.Generated
[error]                  ^

),
grpcExePath := xsbti.api.SafeLazyProxy {
val exe = (LocalRootProject / baseDirectory).value / ".bin" / grpcExeFileName
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.6.2
sbt.version=1.11.0
4 changes: 2 additions & 2 deletions project/plugin.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.19")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7")

libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.8.4"
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.17"
Loading