I'm creating ZIO gRPC client service on scala 2.13.12.
I generated classes from .proto's and trying to compile my project and getting this error:
[error] C:\Users\arsen\IdeaProjects\voicekit-grpc\target\scala-2.13\src_managed\main\scalapb\tinkoff\cloud\stt\v1\SpeechToText\SpeechToTextProto.scala:10:20: object annotations is not a member of package com.google.api
[error] com.google.api.annotations.AnnotationsProto,
[error] ^
[error] C:\Users\arsen\IdeaProjects\voicekit-grpc\target\scala-2.13\src_managed\main\scalapb\tinkoff\cloud\stt\v1\SpeechToText\SpeechToTextProto.scala:129:22: object annotations is not a member of package com.google.api
[error] com.google.api.annotations.AnnotationsProto.javaDescriptor,
[error] ^
[error] two errors found
There is .proto file from API which I want to use in my app:
syntax = "proto3";
package tinkoff.cloud.stt.v1;
option go_package = "github.com/Tinkoff/voicekit-examples/golang/pkg/tinkoff/cloud/stt/v1";
option objc_class_prefix = 'TVKSR';
import "google/protobuf/duration.proto";
import "google/api/annotations.proto";
service SpeechToText { // Speech recognition.
rpc Recognize(RecognizeRequest) returns (RecognizeResponse) { // Method to recognize whole audio at once: sending complete audio, getting complete recognition result.
option (google.api.http) = {
post: "/v1/stt:recognize"
body: "*"
};
}
rpc StreamingRecognize(stream StreamingRecognizeRequest)
returns (stream StreamingRecognizeResponse); // Method for streaming recognition.
rpc StreamingUnaryRecognize(stream StreamingUnaryRecognizeRequest) returns (RecognizeResponse) { // Method to synchronous recognize audio stream. Returns recognition result after all audio has been sent and processed.
option (google.api.http) = {
post: "/v1/stt:streaming_unary_recognize";
body: "*";
};
}
}
......
There is my build.sbt:
import scala.tools.nsc.io.JFile
lazy val root = project
.in(file("."))
.settings(
name := "voicekit-grpc",
version := "0.1.0-SNAPSHOT",
scalaVersion := "2.13.12",
Compile / PB.targets := Seq(
scalapb.gen(grpc = true) -> (Compile / sourceManaged).value / "scalapb",
scalapb.zio_grpc.ZioCodeGenerator -> (Compile / sourceManaged).value / "scalapb"
),
Compile / PB.includePaths ++= Seq(new JFile("third_party/googleapis/")),
libraryDependencies ++= Seq(
"io.grpc" % "grpc-netty" % "1.50.1",
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion,
"com.typesafe" % "config" % "1.4.3",
"dev.zio" %% "zio-http" % "0.0.5",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.16.1",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.16.1",
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf"
)
)
There is my plugins.sbt:
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")
libraryDependencies ++= Seq(
"com.thesamet.scalapb.zio-grpc" %% "zio-grpc-codegen" % "0.6.1")
I searched and manually downloaded external proto dependencies to directory /third_party
I've tried to add multiple paths to external dependencies to PB.includePaths, but it didn't help
Instead of manual downloading files try to add the dependency to build.sbt
"com.google.api.grpc" % "googleapis-common-protos" % "0.0.3" % "protobuf"
or
"com.google.api.grpc" % "proto-google-common-protos" % "2.34.0" % "protobuf"
Please notice % "protobuf"
scope.
https://discuss.lightbend.com/t/use-googles-annotations-proto/3302
Actually, just add google annotations.proto
and http.proto
manually to src/main/protobuf/google/api
.
https://github.com/senyanyash/zio-grpc-test/pull/1
Import "google/api/annotations.proto" was not found or had errors. How do I add it as a dependency?