Nadav, I've been unable to get the code generation for scalapb-validate to work. I'm using akka-grpc, and have tried with akka-grpc versions 1.1.1 (latest) and 1.0.2, and with scalapb-validate versions 0.1.4, 0.2.2, and 0.3.0. I've added this to my build.sbt to reflect the location where the generated protobuf and grpc .scala files are placed.
Compile / PB.targets ++= Seq(
scalapb.validate.gen() -> crossTarget.value / "akka-grpc" / "main"
)
Here are the errors I get with each. Would appreciate any suggestions you have for tweaking versions or settings to get this to work.
0.3.0:
[info] Generating Akka gRPC service interface for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC service handler for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC service power API handler for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC service power API interface for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC client for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
--jvm_4_out: java.lang.NoSuchMethodError: com.google.protobuf.Descriptors$Descriptor.getRealOneofs()Ljava/util/List;
at scalapb.compiler.DescriptorImplicits$ExtendedMessageDescriptor.isSealedOneofType(DescriptorImplicits.scala:500)
at scalapb.compiler.DescriptorImplicits$ExtendedMessageDescriptor.scalaType(DescriptorImplicits.scala:510)
at scalapb.validate.compiler.MessagePrinter.validatorName(CodeGenerator.scala:64)
at scalapb.validate.compiler.MessagePrinter.<init>(CodeGenerator.scala:68)
at scalapb.validate.compiler.CodeGenerator$.$anonfun$process$2(CodeGenerator.scala:46)
0.2.2:
[info] Generating Akka gRPC service interface for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC service handler for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC service power API handler for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC service power API interface for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC client for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
--jvm_4_out: java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: com/google/protobuf/compiler/PluginProtos$CodeGeneratorResponse$Feature
at protocgen.CodeGenResponse.toCodeGeneratorResponse(CodeGenResponse.scala:12)
at protocgen.CodeGenResponse.toCodeGeneratorResponse$(CodeGenResponse.scala:7)
at protocgen.CodeGenResponse$Internal$Success.toCodeGeneratorResponse(CodeGenResponse.scala:36)
at protocgen.CodeGenApp.run(CodeGenApp.scala:46)
at protocgen.CodeGenApp.run$(CodeGenApp.scala:39)
at scalapb.validate.compiler.CodeGenerator$.run(CodeGenerator.scala:20)
at protocgen.CodeGenApp.run(CodeGenApp.scala:31)
at protocgen.CodeGenApp.run$(CodeGenApp.scala:30)
at scalapb.validate.compiler.CodeGenerator$.run(CodeGenerator.scala:20)
0.1.4:
[info] Generating Akka gRPC service interface for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC service handler for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC service power API handler for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC service power API interface for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
[info] Generating Akka gRPC client for com.livongo.protobuf.grpc.internal_non_production.pregistry.PatientRegistry
com/livongo/protobuf/grpc/internal_non_production/pregistry/pregistry/GetWalletRequest.scala: Tried to insert into file that doesn't exist.
com/livongo/protobuf/grpc/internal_non_production/pregistry/pregistry/ListWalletsRequest.scala: Tried to insert into file that doesn't exist.
...
When I disable validation, the generated files are placed in target/scala-2.12/akka-grpc/main/com/livongo/protobuf/grpc/internal_non_production/pregistry, and crossTarget.value is target/scala-2.12. I've tried all these variants to try to get it to "find" the generated files that it says doesn't exist, and get the same errors with every one of them.
Compile / PB.targets ++= Seq(
// scalapb.validate.gen() -> crossTarget.value
// scalapb.validate.gen() -> crossTarget.value / "akka-grpc"
scalapb.validate.gen() -> crossTarget.value / "akka-grpc" / "main"
// scalapb.validate.gen() -> crossTarget.value / "akka-grpc" / "main" / "com" / "livongo" / "protobuf" / "grpc" / "internal_non_production" / "pregistry"
)
Here's the value of protocTargets, which shows the target/scala-2.12/akka-grpc/main directory:
$ inspect compile:protocTargets
[info] Setting: scala.collection.Seq[protocbridge.Target] = List(Target(SandboxedJvmGenerator(scala,com.thesamet.scalapb:compilerplugin_2.12:0.10.8(crossVersion=false),List(com.thesamet.scalapb:scalapb-runtime:0.10.8(crossVersion=true)),protocbridge.SandboxedJvmGenerator$$$Lambda$6024/1316158537@74ed9cd6),/Users/christoomey/unix/dev/grpcValidationUpgrade/target/scala-2.12/akka-grpc/main,List(flat_package)), Target(SandboxedJvmGenerator(akka-grpc-scaladsl-trait,com.lightbend.akka.grpc:akka-grpc-codegen_2.12:1.0.2(crossVersion=false),List(com.lightbend.akka.grpc:akka-grpc-runtime_2.12:1.0.2(crossVersion=false)),akka.grpc.sbt.GeneratorBridge$$$Lambda$6049/1040418078@2de8cadc),/Users/christoomey/unix/dev/grpcValidationUpgrade/target/scala-2.12/akka-grpc/main,List(flat_package, server_power_apis, use_play_actions)), Target(SandboxedJvmGenerator(akka-grpc-scaladsl-server,com.lightbend.akka.grpc:akka-grpc-codegen_2.12:1.0.2(crossVersion=false),List(com.lightbend.akka.grpc:akka-grpc-runtime_2.12:1.0.2(crossVersion=false)),akka.grpc.sbt.GeneratorBridge$$$Lambda$6049/1040418078@51c6e209),/Users/christoomey/unix/dev/grpcValidationUpgrade/target/scala-2.12/akka-grpc/main,List(flat_package, server_power_apis, use_play_actions)), Target(SandboxedJvmGenerator(akka-grpc-scaladsl-client,com.lightbend.akka.grpc:akka-grpc-codegen_2.12:1.0.2(crossVersion=false),List(io.grpc:grpc-stub:1.32.1(crossVersion=false), com.lightbend.akka.grpc:akka-grpc-runtime_2.12:1.0.2(crossVersion=false)),akka.grpc.sbt.GeneratorBridge$$$Lambda$6049/1040418078@5b031055),/Users/christoomey/unix/dev/grpcValidationUpgrade/target/scala-2.12/akka-grpc/main,List(flat_package, server_power_apis, use_play_actions)), Target(SandboxedJvmGenerator(scala,com.thesamet.scalapb:scalapb-validate-codegen_2.12:0.1.4(crossVersion=false),List(com.thesamet.scalapb:scalapb-validate-core:0.1.4(crossVersion=true)),protocbridge.SandboxedJvmGenerator$$$Lambda$6024/1316158537@43902ccf),/Users/christoomey/unix/dev/grpcValidationUpgrade/target/scala-2.12,List()))