Questions tagged [scalapb]

ScalaPB is a protocol buffer compiler (protoc) plugin for Scala. It generates Scala case classes, parsers and serializers for protocol buffers.

Main features:

Built on top of Google’s protocol buffer compiler to ensure perfect compatibility with the language specification.

Nested updates are easy by using lenses:

val newOrder = order.update(_.creditCard.expirationYear := 2015)

Generated case classes can co-exist alongside the Java-generated code (the class names will not clash). This allows gradual transition from Java to Scala.

Can optionally generate conversion methods between the Java generated version of Protocol Buffers to the Scala generated version. This makes it possible to migrate your project gradually.

Supports for Oneof’s that were introduced in Protocol Buffers 2.6.0.

Learn more here: https://scalapb.github.io/index.html

Source code: https://github.com/scalapb/ScalaPB

104 questions
2
votes
2 answers

Bringing third party .proto files to ScalaPB

How can I tell ScalaPB that it should fetch .proto dependencies from the Internet, e.g. google/api/annotations.proto from https://github.com/googleapis/googleapis/tree/master/google/api Background: The aim is to read etcd v3 API from Scala, via…
akauppi
  • 17,018
  • 15
  • 95
  • 120
2
votes
0 answers

*.proto files are ignored

Im trying to use protobuffers and scalaPB, i've added: import com.trueaccord.scalapb.compiler.Version.scalapbVersion libraryDependencies += "com.trueaccord.scalapb" %% "scalapb-runtime" % scalapbVersion % "protobuf" PB.targets in Compile := Seq( …
hi_my_name_is
  • 4,894
  • 3
  • 34
  • 50
2
votes
1 answer

ScalaPB with Scala.js and Scala(jvm) - There were linking errors

I have multiple subprojects in my sbt, one being a server (base upon playframework) the other being the clientside (scala.js) and the third one being the communication between the two in form of protobuf (scalapb). Now, this is my build.sbt: lazy…
user4063815
2
votes
0 answers

ScalaPB and shading with SBT isn't working

I'm trying to get https://scalapb.github.io/">ScalaPB to work with Spark. In order to do this I need to shade my protocol buffers within SBT using code like below assemblyShadeRules in assembly := Seq( ShadeRule.rename("com.google.protobuf.**" ->…
Jon
  • 3,985
  • 7
  • 48
  • 80
2
votes
2 answers

Generate both Java and Scala classes using Protocol Buffers in ScalaPB

I have been using sbt-protobuf to generate Java classes from proto definition files. I now want to generate Scala classes as well. To do that, I try to use the ScalaPB plugin. The goal is to have one src/main/protobuf/ directory in the project and…
marios
  • 8,874
  • 3
  • 38
  • 62
2
votes
1 answer

Compiling protocol buffers with ScalaPBC for Scala 2.10?

I'm trying to compile a simple protobuf file to Scala using Trueaccord's ScalaPBC. I'm restricted to Scala 2.10, and the resulting classes cannot be compiled due to an implementation restriction on case classes ("case classes cannot have more than…
1
vote
0 answers

How to compile the protofile

need a help, I don't have idea about how to compile for proto useing scalapb syntax = "proto2"; package com.test; import "ImageElement.proto"; import "Color.proto"; message BadgeBackground { optional string id = 1; oneof bg_oneof { …
Mathan P
  • 11
  • 1
1
vote
1 answer

Is there a way to get all possible protobuf Enum values using scalapb?

I have a protobuf enum like enum MyEnum { A = 0; B = 1; C = 2; } At runtime, I want to loop over all possible values for the enum like this: MyEnum().uniqueValues.forEach(println) How might I do this with scalapb or just in scala?
tSchema
  • 193
  • 2
  • 12
1
vote
0 answers

java.lang.VerifyError: class frameless.functions.Spark2_4_LambdaVariable overrides final method genCode

I am running a databricks job that uses ProtoSQL.udf. The data frame has a column that has encoded protoValue. The parse method is used to create a new column which stores json extracted from protoValue. scalaVersion = 2.12 scalapb.version =…
1
vote
1 answer

How to describe Option[FiniteDuration] in proto with scalapb

I am trying to use proto3 and scalapb, but I am unable to map FiniteDuration as well as unable to use it as Option. Can anyone please advise on the same case class Message(id:Int , interval: Option[FiniteDuration])
coder25
  • 2,363
  • 12
  • 57
  • 104
1
vote
1 answer

How to generically unpack google.protobuf.Any on Spark with ScalaPB at runtime?

I have the following protobuf setup: import "google/protobuf/any.proto"; message EntityEnvelope { string id = 1; string entity_type = 2; google.protobuf.Any entity = 3; } message EntityABC { string name = 1; } message EntityXYZ { string…
Mike Dias
  • 195
  • 1
  • 11
1
vote
0 answers

Unable to call method from scala protobuf jar

I have define scala object(say, MyObject) which extends following trait GeneratedMessageCompanion[A <: GeneratedMessage with Message[A]] And when I call parseFrom method on the object, I get following error: Caused by:…
Mandroid
  • 6,200
  • 12
  • 64
  • 134
1
vote
1 answer

Use any previous message in a new message

I have a protobuf file in which I define multiple messages which all inherit the same trait (using option (scalapb.message).extends = "Event"; inside of message definition). I would like to create a new message called MultiEvent which may contain…
Darko
  • 113
  • 7
1
vote
1 answer

In Akka-typed, how to deserialize a serialized ActorRef without its ActorSystem?

I'm very new to the Akka World, much less on Akka-typed. Sorry too if this one's stupid, :( So, I followed the Request-Response interaction pattern, for actors to interact. That means adding an actorRef in my commands. However my commands are all…
Jitterbug
  • 302
  • 1
  • 11
1
vote
1 answer

How to generate protobuf Enum as String using ScalaPB?

I have the following in my Protobuf message: enum SegmentType { UNKNOWN = 0; TYPE_1 = 1; TYPE_2 = 2; TYPE_3 = 3; } optional SegmentType segment_type = 1 [default = UNKNOWN] Instead of GeneratedEnum type, I would like to…
mmziyad
  • 298
  • 1
  • 4
  • 16