scalapb

scalapb how to generate code from protobuf files in test directory?

二次信任 提交于 2019-12-13 03:43:30
问题 I'd like to generate code from protobuf files in test directory. project/test/protobuf/myproto.proto This doesn't work. PB.targets in Test := Seq( scalapb.gen() -> (sourceManaged in Test).value ) Looks like scalapb only generates files for protos in main/protobuf directory. 回答1: You need to enable ScalaPB code generator for your test configuration. Add this to build.sbt : Project.inConfig(Test)(sbtprotoc.ProtocPlugin.protobufConfigSettings) 来源: https://stackoverflow.com/questions/49693643

Error when decoding the Proto Buf messages in Spark Streaming , using scalapb

丶灬走出姿态 提交于 2019-12-10 21:13:29
问题 This is a Spark Streaming app that consumes Kafka messages encoded in Proto Buf . Using scalapb library. I am getting the following error. Please help. > com.google.protobuf.InvalidProtocolBufferException: While parsing a > protocol message, the input ended unexpectedly in the middle of a > field. This could mean either that the input has been truncated or > that an embedded message misreported its own length. at > com.google.protobuf.InvalidProtocolBufferException.truncatedMessage

How to serialize/deserialize a protobuf message that uses 'oneof' with ScalaPB?

[亡魂溺海] 提交于 2019-12-06 08:27:11
问题 I'm using ScalaPB to compile my Scala case classes for serializing my protobuf messages. I have a .proto file with the following messages: message WrapperMessage { oneof msg { Login login = 1; Register register = 2; } } message Login { required string email = 1; required string password = 2; } message Register { required string email = 1; required string password = 2; optional string firstName = 3; optional string lastName = 4; } How do I create my WrapperMessage knowing that I want to put a