Using grpc in maven

Viewed 16681

Does anyone know how to compile *.proto files for grpc application in maven?

This is how I'm compiling protobuf in maven - (old way, using installed protoc compiler, excerpt from pom.xml):

  <build>
    <plugins>

      <!-- protocol buffers runner, requires protoc -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-protobuf-sources</id>
            <phase>generate-sources</phase>
            <configuration>
              <tasks>
                <mkdir dir="target/generated-sources/java" />

                <exec executable="protoc">
                  <arg value="--java_out=target/generated-sources/java" />
                  <arg value="src/main/protobuf/hello.proto" />
                </exec>
              </tasks>
              <sourceRoot>target/generated-sources/java</sourceRoot>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

I wonder if something similar is possible for grpc. From what I understand I need to somehow connect protoc-gen-grpc-java plugin with protobuf, but I'm not sure how to do that.

UPDATE: For those who interested I created a fully working example of client-server app using maven on github.

1 Answers
Related