typelevel / typelevel/fs2-grpc
Support generating code from proto in src/test/protobuf
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 284
- Forks
- 66
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 4
Description
We have proto files in src/test/protobuf which doesn't seem to be supported out of the box. To get it to work I've had to copy paste some settings from https://github.com/typelevel/fs2-grpc/blob/90fe82c78470f74ea49981701ff8dfb736792412/plugin/src/main/scala/fs2/grpc/codegen/Fs2GrpcPlugin.scala#L103.
inConfig(Test)(
Seq(
PB.targets := Fs2GrpcPlugin.autoImport.scalapbCodeGenerators.value,
PB.protoSources := Seq(sourceDirectory.value / "protobuf"),
fs2GrpcServiceSuffix := "Fs2Grpc",
fs2GrpcOutputPath := sourceManaged.value / "fs2-grpc",
scalapbCodeGeneratorOptions := Seq(CodeGeneratorOption.Grpc, CodeGeneratorOption.Fs2Grpc),
scalapbCodeGenerators := {
val options = scalapbCodeGeneratorOptions.value.toSet
Target(
scalapb.gen(
flatPackage = options(CodeGeneratorOption.FlatPackage),
javaConversions = options(CodeGeneratorOption.JavaConversions),
grpc = options(CodeGeneratorOption.Grpc),
singleLineToProtoString = options(CodeGeneratorOption.SingleLineToProtoString),
asciiFormatToString = options(CodeGeneratorOption.AsciiFormatToString)
),
sourceManaged.value / "scalapb"
) ::
Option(
Target(
(
SandboxedJvmGenerator.forModule(
"scala-fs2-grpc",
Artifact(
BuildInfo.organization,
s"${BuildInfo.codeGeneratorName}_${CrossVersion.binaryScalaVersion(BuildInfo.scalaVersion)}",
BuildInfo.version
),
BuildInfo.codeGeneratorFullName + "$",
Nil
),
scalapbCodeGeneratorOptions.value.filterNot(_ == CodeGeneratorOption.Fs2Grpc).map(_.toString) :+
s"serviceSuffix=${fs2GrpcServiceSuffix.value}"
),
fs2GrpcOutputPath.value
)
).filter(_ => scalapbCodeGeneratorOptions.value.contains(CodeGeneratorOption.Fs2Grpc)).toList
}
)
)
It would be good if we supported this out of the box like Akka gRPC does here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with plugin/src/main/scala/fs2/grpc/codegen/Fs2GrpcPlugin.scala and compare its configuration with the linked Akka gRPC Test setup. Trace the existing scalapb and Fs2Grpc generator settings, then verify that proto files under src/test/protobuf are generated automatically without the issue's copied configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- grpc, scala
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100