Generate Code from Thrift Definitions
You've created Thrift definitions (structs, services, etc.) and you need to generated 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 myproject/src/thrift: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) and
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 myproject/src/main/thrift:thrift-java
create_thrift_libraries targets work somewhat differently, however.