sbt-protoc | SBT plugin for generating code | Plugin library
kandi X-RAY | sbt-protoc Summary
kandi X-RAY | sbt-protoc Summary
SBT plugin for generating code from Protocol Buffer using protoc
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of sbt-protoc
sbt-protoc Key Features
sbt-protoc Examples and Code Snippets
Community Discussions
Trending Discussions on sbt-protoc
QUESTION
I'm trying to use Protocol Buffers for generate Scala case classes.
Base settings are: 1.In project/plugins.sbt:
...ANSWER
Answered 2021-Sep-21 at 14:12It works as intended. The case class generated has members for each of the fields in the proto. The rest of the generated code takes care of serialization and deserialization. You can read more about the generated code and how to use it here: https://scalapb.github.io/docs/generated-code
QUESTION
I'm using ScalaPB (version 0.11.1) and plugin sbt-protoc (version 1.0.3) to try to compile an old project with ProtocolBuffers in Scala 2.12. Reading the documentation, I want to set the file property preserve_unknown_fields
to false
. But my question is, where? Where do I need to set this flag? On the .proto file?
I've also tried to include the flag as a package-scoped option by creating a package.proto file next to my other .proto file, with the following content (as it is specified here):
...ANSWER
Answered 2021-Apr-20 at 05:50From the docs:
If you are using sbt-protoc and importing protos like scalapb/scalapb.proto, or common protocol buffers like google/protobuf/wrappers.proto:
Add the following to your build.sbt:
libraryDependencies += "com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf"
This tells sbt-protoc to extract protos from this jar (and all its dependencies, which includes Google's common protos), and make them available in the include path that is passed to protoc.
It is important to add that by setting preserve_unknown_fields
to false you are turning off a protobuf feature that could prevent data loss when different parts of a distributed system are not running the same version of the schema.
QUESTION
I have a library that needs two different versions of "com.thesamet.scalapb" %% "compilerplugin"
depending on the Scala version.
In my project/scalapb.sbt
I have this code:
ANSWER
Answered 2020-Oct-22 at 19:58sbt files in the project
directory are evaluated before a specific scala version is picked up for cross building. This is why passing ++2.11.12
has no effect on scalaBinaryVersion
in the context of project/scalapb.sbt
.
Using different versions of compilerplugin in a single build is not officially supported at this point, but there are a few workarounds that you can try:
- Download scalapbc for the version of ScalaPB you would like to use. Write a shell script that generates sources using ScalaPBC. Check in the generated sources into your code repository. Manually add scalapb-runtime into your libraryDependencies in build.sbt:
QUESTION
Using the Person
and Address
message definition in https://scalapb.github.io/generated-code.html
ANSWER
Answered 2020-Mar-27 at 09:19In your implementation, you do not have optional fields. If you want to have an optional field you need to write code like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sbt-protoc
To download an artifact and use it as a code generator plugin:.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page