Buf v0.27.1 is released - buf generate is out of beta

49 views
Skip to first unread message

bufbuild-announce

unread,
Oct 16, 2020, 10:52:45 AM10/16/20
to bufbuild-announce
We have released Buf v0.27.1.

This moves buf beta generate out of beta to buf generate. We're now exclusively using buf generate for our Protobuf stub generation, and find it to be a much easier experience than using protoc.

This command uses a template file of the shape:

version: v1beta1         # required
plugins:
  - name: go             # required
    out: gen/go          # required
    opt: plugins=grpc    # optional
    path: custom-gen-go  # optional
  - name java
    out: gen/java

By default, buf generate will look for a file of this shape named buf.gen.yaml in your current directory. This can be thought of as a template for the set of plugins you want to invoke. Then, call with:

# uses buf.gen.yaml as template, current directory as input
$ buf generate

# same as the defaults
$ buf generate --input . --template buf.gen.yaml

# --template also takes YAML or JSON data as input, so it can be used without a file
$ buf generate --input . --template '{"version":"v1beta1","plugins":[{"name":"go","out":"gen/go"}]}'

# download the repository, compile it, and generate per the bar.yaml template
$ buf generate --input https://github.com/foo/bar.git --template bar.yaml

# generate to the bar/ directory, prepending bar/ to the out directives in the template
$ buf generate --input https://github.com/foo/bar.git --template bar.yaml -o bar


The paths in the template and the -o flag will be interpreted as relative to your current directory, so you can place your template files anywhere.

Plugins are invoked in the order they are specified in the template, but each plugin has a per-directory parallel invocation, with results from each invocation combined before writing the result. This is equivalent behavior to buf protoc --by_dir.
Reply all
Reply to author
Forward
0 new messages