Generate Code from Thrift Definitions
You've created Thrift definitions (structs, services, etc.) and you need to generate either Thrift-based
- classes for use within your Scala or Java project, or
- libraries that can be used by your project or other projects.
gen goal to generate code from Thrift definitions. Here's an example:
$ ./pants gen src/thrift/example:thrift-scala
If you need to compile a Scala or Java library target instead, use the
compile goal instead.
There are two types of Thrift target definitions that you will find in
BUILD files in existing projects:
java_thrift_library(for Scala and Java)
You can use the
compile goals directly with
java_thrift_library targets. Thus, you could target a
BUILD file containing this definition...
java_thrift_library( name='thrift-java', # Other parameters )
...like this using Pants:
$ ./pants gen src/thrift/example:thrift-java
To learn more about Thrift, check out the Thrift Example docs.