Seamless Gradle integration with the Buf CLI

Alan Chiu on Aug 9, 2023/2 min read

We built the Buf CLI to be a one-stop shop for Protobuf development. In addition to code generation, the CLI offers features such as linting, formatting, and backward compatibility validation. This unified tool serves as the basis for a dramatically upgraded experience of working with Protobuf, and we’re excited to bring this experience to Gradle projects!

Gradle and the Buf CLI

When using Protobuf schemas to build Java and Kotlin clients with the Buf CLI, developers typically generate outputs manually and check them into source control. Additionally, other housekeeping tasks such as linting and validating backward compatibility are done manually. We now provide a Gradle plugin with a set of tasks that encapsulate Buf CLI invocations to simplify these workflows and eliminate the need to check in generated code:

  • bufGenerate: Generates Java/Kotlin sources from Protobuf schemas with buf generate. This can be run as part of the build process, eliminating the need for checking in generated code.
  • bufBreaking: Checks Protobuf schemas against a previous version for backward-incompatible changes using the buf breaking functionality.
  • bufFormatCheck/bufFormatApply: Validates and enforces formatting of Protobuf files using buf format.
  • bufLint: Runs lint checks using buf lint.

To learn more about the Gradle plugin and how to integrate it, check out our documentation.

Community collaboration

This plugin was originally created and developed by Andrew Parmet, an enthusiastic member of the Buf community. We’re very grateful for Andrew’s contributions to this effort, and for his collaboration in making this an officially supported Buf tool. Andrew will continue to be involved as a contributor and maintainer of the repository along with Buf!

Get started

Head over to the usage documentation to integrate Buf into your Gradle project. You can also check out the plugin on GitHub and come join us on Slack — we’d love to chat, answer questions, and hear feedback!

Get started for free with the Buf Schema Registry