rebar3_thrift
View SourceA rebar3 plugin that runs the
thrift_generator IDL
compiler over the Thrift IDL files declared in your rebar.config and
keeps the generated Erlang sources fresh. The generated code depends
on thrift_runtime — add it
to your deps.
Install
%% rebar.config
{plugins, [rebar3_thrift]},
{deps, [thrift_runtime]},
{thrift, [
{files, ["src/my_api.thrift"]}, %% required, one or more IDL files
{out_dir, "src"} %% optional, default "src"
]}.Commands
rebar3 thrift— (re)generate the Erlang sources for every declared IDL file. Files whose content is already up to date are left untouched, so regenerating an unchanged IDL does not churn mtimes. To generate before every compilation, hook it in yourrebar.config:{provider_hooks, [{pre, [{compile, {default, thrift}}]}]}.rebar3 thrift --check— verify instead of write: fails when any generated artifact is missing or stale relative to its IDL — a freshness gate for CI.rebar3 thrift clean— delete generated files from the out dir: every.erl/.hrlcarrying the generator's autogenerated banner, so files orphaned by a removed service or a deleted IDL go too. Hook into cleanup with{provider_hooks, [{post, [{clean, {thrift, clean}}]}]}.
Four optional option axes in {thrift, [...]} mirror the generator's
CLI flags and apply only where the IDL carries no explicit annotation
of its own: {repr, record | map | native},
{union_type, record | sum}, {set, list | sets | ordset},
{typedef_type, alias | nominal}.
See the repository README for the full story.
License
Apache-2.0 — see LICENSE.md.