StackLeader Blog

Post Image
Jun 24, 2016

Generating gRPC Code using Maven


This post will cover how to generate a gRPC api jar from a .proto service contract using Maven. This generated api jar can then be used to implement a gRPC service implementation and/or a client for consuming a gRPC service.

Source Code

The source code for this example is available on github.

Project Structure

Tree View


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" 


                      The version of protoc must match protobuf-java. If you don't depend on
                      protobuf-java directly, you will be transitively depending on the
                      protobuf-java version that grpc depends on.
                        -exportcontents: *


syntax = "proto3";

option java_multiple_files = true;
option java_package = "";
option java_outer_classname = "HelloWorld";
option objc_class_prefix = "HLW";

package helloworld;

// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;

// The response message containing the greetings
message HelloReply {
  string message = 1;

Generated Source Code

Generated Source Code

Implementing gRPC Service and Client

In Part 2 we will cover the basics of how to implement a gRPC service and client using the API jar generated from this maven build.