Scrooge¶
Scrooge is a thrift code generator written in Scala, which currently generates code for Scala, Java, Cocoa, Android and Lua.
It’s meant to be a replacement for the apache thrift code generator, and generates conforming, binary-compatible codecs by building on top of libthrift.
Since Scala is API-compatible with Java, you can use the apache thrift code generator to generate Java files and use them from within Scala, but the generated code uses Java collections and mutable “bean” classes, causing some annoying boilerplate conversions to be hand-written. This is an attempt to bypass the problem by generating Scala code directly. It also uses Scala syntax so the generated code is much more compact.
There is a fairly comprehensive set of unit tests, which actually generate code, compile it, and execute it to verify expectations.
Features¶
Generates native Scala thrift codecs
Generated code is templated using a mustache variant, making it easy to edit.
Finagle client/server adaptors can be optionally generated at the same time.
Has a pluggable backend providing a dynamic way to add more generator targets.
Using Scrooge¶
There are a couple of classes needed by the generated code. These have been moved out of scrooge into a separate jar to keep dependencies small. Maven users need to add the following to the pom.xml file:
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-core_2.12</artifactId>
<version>24.2.0</version>
</dependency>
SBT users need this:
val scroogeCore = "com.twitter" %% "scrooge-core" % "24.2.0"
Building Scrooge¶
To build scrooge, use sbt:
$ ./sbt publishLocal
This will currently not build and publish the scrooge-sbt-plugin. You can still build the scrooge-sbt-plugin separately by executing:
$ ./sbt
> project scrooge-sbt-plugin
> publishLocal
User’s guide¶
- Namespaces
- SBT Plugin
- Maven Plugin
- Command Line
- Finagle Integration
- Dependencies of the generated code
- Generated Scala Code Usage
- Implementation Semantics
- Scrooge thrift linter
- Swift User Guide
- Thrift Validation
Notes¶
- Scrooge Changelog
- Unreleased
- 24.2.0
- 23.11.0
- 22.12.0
- 22.7.0
- 22.4.0
- 22.3.0
- 22.2.0
- 22.1.0
- 21.12.0
- 21.11.0
- 21.10.0
- 21.9.0
- 21.8.0 (No 21.7.0 Release)
- 21.6.0
- 21.5.0
- 21.4.0
- 21.3.0
- 21.2.0
- 21.1.0
- 20.12.0
- 20.10.0
- 20.9.0
- 20.8.1
- 20.8.0 (DO NOT USE)
- 20.7.0
- 20.6.0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