xolstice / protobuf-maven-plugin

Maven Plugin that executes the Protocol Buffers (protoc) compiler
https://www.xolstice.org/protobuf-maven-plugin/
Other
232 stars 76 forks source link

unable to resolve google.protobuf.Empty #28

Closed mgenov closed 7 years ago

mgenov commented 7 years ago

Please answer these questions before submitting your issue.

What version of gRPC are you using?

1.4.0

What JVM are you using (java -version)?

java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

protoc version

libprotoc 3.3.0

Properties

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <kotlin.version>1.1.2-5</kotlin.version>
    <grpc.version>1.4.0</grpc.version><!-- CURRENT_GRPC_VERSION -->
  </properties>

Plugin definition

  <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>0.5.0</version>
        <configuration>
          <protocArtifact>com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}</protocArtifact>
          <pluginId>grpc-java</pluginId>
          <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>compile-custom</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

Extensions

<build>
 <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.4.1.Final</version>
      </extension>
    </extensions>
   ....
</build>

What did you do?

mvn clean compile

What did you expect to see?

BUILD SUCCESS

What did you see instead?

[INFO] Compiling 2 proto file(s) to ..../target/generated-sources/protobuf/java [ERROR] PROTOC FAILED: myservice.proto:40:59: "google.protobuf.Empty" is not defined.

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------

I'm I able to resolve it or I have to define my own Empty message ?

Note that the google.api.http type is resolved successfully.

sergei-ivanov commented 7 years ago

Hello Miroslav,

A quick check: is com.google.protobuf:protobuf-java included in your compile dependencies? This is where google.protobuf.Empty is packaged.

Kind regards, Sergei

mgenov commented 7 years ago

I've tried version 3.0.0 and 3.3.1 and it doesn't resolve the issue. This is how my dependency tree looks:

screen shot 2017-06-26 at 7 37 29 am
sergei-ivanov commented 7 years ago

Can you reproduce it in a small-scale sample project? I am pretty sure something trivial is missing from your configuration, but I do not have enough information to tell what it is exactly.

mgenov commented 7 years ago

It was a silly mistake. I've forgot to include the import path in my proto definition:

import "google/protobuf/empty.proto";

and this was the cause.

Thanks for your feedback @sergei-ivanov

sergei-ivanov commented 7 years ago

I suspected something like that :) I am glad your issue has been resolved.