Maven build does not generate code with grpc-java

Viewed 1456

I am trying to generate code for a gRPC application, with Java, Maven and Intellij.

I followed the documentation of grpc-java https://github.com/grpc/grpc-java/blob/master/README.md, but when I build the project, no code is generated.

Here is my pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.nolapps</groupId>
    <artifactId>grpc-simpleapp</artifactId>
    <version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-netty-shaded</artifactId>
        <version>1.35.0</version>
    </dependency>
    <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-protobuf</artifactId>
        <version>1.35.0</version>
    </dependency>
    <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-stub</artifactId>
        <version>1.35.0</version>
    </dependency>
    <dependency> <!-- necessary for Java 9+ -->
        <groupId>org.apache.tomcat</groupId>
        <artifactId>annotations-api</artifactId>
        <version>6.0.53</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
    <build>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.6.2</version>
            </extension>
        </extensions>
        <plugins>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.6.1</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:3.12.0:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.35.0:exe:${os.detected.classifier}</pluginArtifact>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

And My proto file is in src/main/proto (messages.proto)

syntax = "proto3";

option java_package="grpc.messages";

message Employee {
    int32 id = 1;
    int32 badgeNumber = 2;
    string firstName = 3;
    string lastName = 4;
    float vacationAccrualRate = 5;
    float vacationAccrued = 6;
}

message GetAllRequest {}

message GetByBadgeNumberRequest {
    int32 badgeNumber = 1;
}

message EmployeeRequest {
    Employee employee = 1;
}

message EmployeeResponse {
    Employee employee = 1;
}

message AddPhotoRequest {
    bytes data = 1;
}

message AddPhotoResponse {
    bool isOk = 1;
}

service EmployeeService {
    rpc GetByBadgeNumber (GetByBadgeNumberRequest) returns (EmployeeResponse);
    rpc GetAll (GetAllRequest) returns (stream EmployeeResponse);
    rpc Save (EmployeeRequest) returns (EmployeeResponse);
    rpc SaveAll (EmployeeRequest) returns (stream EmployeeResponse);
    rpc AddPhoto (AddPhotoRequest) returns (AddPhotoResponse);
}

To build the project, (from Intelij), I go to: Build -> Build Project. But nothing happens.

My question: Any idea why my code is not generated?

0 Answers
Related