Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scalapb/ScalaPB
Protocol buffer compiler for Scala.
https://github.com/scalapb/ScalaPB
protocol-buffers scala scalapb
Last synced: 25 days ago
JSON representation
Protocol buffer compiler for Scala.
- Host: GitHub
- URL: https://github.com/scalapb/ScalaPB
- Owner: scalapb
- License: apache-2.0
- Created: 2014-10-02T01:11:41.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-11-15T21:01:08.000Z (28 days ago)
- Last Synced: 2024-11-15T22:17:50.630Z (27 days ago)
- Topics: protocol-buffers, scala, scalapb
- Language: Scala
- Homepage: https://scalapb.github.io/
- Size: 9.82 MB
- Stars: 1,308
- Watchers: 44
- Forks: 284
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-scala-native - ScalaPB - [Protocol Buffer](https://developers.google.com/protocol-buffers/) compiler for Scala. (File Formats and Parsers)
- awesome-scala - **ScalaPB** - activity/y/scalapb/ScalaPB) (Table of Contents / Serialization)
README
ScalaPB
=======[![ScalaPB runtime version support](https://index.scala-lang.org/scalapb/scalapb/scalapb-runtime/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/scalapb/scalapb/scalapb-runtime)
[![Join the chat at https://gitter.im/ScalaPB/community](https://badges.gitter.im/ScalaPB/community.svg)](https://gitter.im/ScalaPB/community)
[![Build Status](https://github.com/scalapb/ScalaPB/workflows/CI/badge.svg)](https://github.com/scalapb/ScalaPB/actions?query=workflow%3ACI)
ScalaPB is a protocol buffer compiler (`protoc`) plugin for Scala. It will
generate Scala case classes, parsers and serializers for your protocol
buffers.ScalaPB generates case classes that can co-exist in the same project alongside
the Java-generated code for ProtocolBuffer. This makes it easy to gradually
migrate an existing project from the Java version of protocol buffers to
Scala. This is achieved by having the ScalaPB generated code use the proto
file as part of the package name (in contrast to Java which uses the file name
in CamelCase as an outer class)Each top-level message and enum is written to a separate Scala file. This
results in a significant improvement in incremental compilations.Another cool feature of ScalaPB is that it can optionally generate methods
that convert a Java protocol buffer to a Scala protocol buffer and vice versa.
This is useful if you are gradually migrating a large code base from Java
protocol buffers to Scala. The optional Java conversion is required if you
want to use `fromAscii` (parsing ASCII representation of a protocol buffer).
The current implementation delegates to the Java version.Highlights
==========- Supports proto2 and proto3
- Easily update nested structure in functional way using lenses
- Scala.js integration
- GRPC integration
- Compatible with SparkSQL (through a helper library)
- Conversion to and from JSON
- Support user-defined options (since 0.5.29)
- Support extensions (since 0.6.0)
Versions
========Version | Description
------- | -----------
0.6.x | Stable. Supports Protobuf 2.6.x to 3.5.x
0.5.x | Supports Protobuf 2.6.x and Protobuf 3.1.x.
0.4.x | Stable, unsupported. Works with Protobuf 2.6.xInstalling
==========To automatically generate Scala case classes for your messages add ScalaPB's
sbt plugin to your project. Create a file named `project/protoc.sbt`
containing the following line:addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.3"
Add the following line to your `build.sbt`:
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
)For additional configuration options, see [ScalaPB SBT Settings](https://scalapb.github.io/docs/sbt-settings) documentation
Using ScalaPB
=============Documentation is available at [ScalaPB website](https://scalapb.github.io/).
Questions?
==========See [contacting us](https://scalapb.github.io/docs/contact).
Testing
=======ScalaPB uses ScalaCheck to aggressively test the generated code. The test
generates many different sets of proto files. The sets are growing in
complexity: number of files, references to messages from other protos, message
nesting and so on. Then, test data is generated to populate this protocol
schema, then we check that the ScalaPB generated code behaves exactly like
the reference implementation in Java.Running the tests:
$ sbt test
The tests take a few minutes to run. There is a smaller test suite called
`e2e` that uses the sbt plugin to compile the protos and runs a series of
ScalaChecks on the outputs. To run it:$ ./e2e.sh
Sponsors
========
We are very thankful to our sponsors:* [Pentech Ltd](https://github.com/PentechLtd)
* [Evgeny Rubtsov (bikaras)](https://github.com/bikaras)
* [@dejvid](https://github.com/dejvid)
* [Andrew Selvia](https://github.com/andrew-selvia)
* [Vitaly Lavrov](https://github.com/lavrov)