Skip to main content
  1. Posts/

Configuring Protobuf to Java compiler in maven

Table of Contents

Here are few steps to configure protobuf-to-java compilation in your maven project:

Install google protobuf compiler on your computer.

brew install protobuf

Configure maven protobuf compiler plugin and protobuf-java dependency in pom.xml


<?xml version='1.0' encoding='UTF-8'?>

Create protobuf definition files within /src/main/proto/ directory. You may want to specify the following options in .proto files.

package com.example;
option java_multiple_files = true;
option java_outer_classname = "Messages";

Run mvn generate-sources and you’re done!