xolstice / protobuf-maven-plugin

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

Only getting OuterClasses - no service classes generated #35

Closed magick93 closed 5 years ago

magick93 commented 7 years ago

Hello When I generate, using the following, I am not getting any service stubs generated. I only get OuterClasses.

<extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.4.1.Final</version>
            </extension>
        </extensions>
        <plugins>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.5.0</version>
                <configuration>
                    <clearOutputDirectory>false</clearOutputDirectory>
                    <protocArtifact>com.google.protobuf:protoc:3.4.0:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.6.1:exe:${os.detected.classifier}</pluginArtifact>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

Any idea what I am doing wrong?

sergei-ivanov commented 7 years ago

The configuration looks OK to me. Can you provide a complete example as a gist?

magick93 commented 7 years ago

Hi @sergei-ivanov

I am still working on getting a sample together.

In the meantime, perhaps you can help me understanding something. Why is <goal>compile-custom</goal> used?

The documentation says:

protobuf:compile-custom compiles main .proto definitions using a custom protoc plugin.

From my understanding this is used to call a custom protoc generator, eg, if a user wanted to make their own generator that parses, and generates, from proto files.

Also, what does "compile" actually mean in this situation? Would a more correct work be transpile?

sergei-ivanov commented 7 years ago

compile-custom goal allows to use custom plugins with protoc (protobuf compiler). gRPC plugin is one of them. Basically, they are standalone executable files that are invoked by protoc and passed protobuf metadata that allows them to generate any custom output from proto files. For example, they may support generating protobuf bindings for exotic programming languages or generating alternative implementations. The prefix compile is historic and relates to protoc, which stands for protobuf compiler.

nobeh commented 6 years ago

I had the same issue, you need to use

<clearOutputDirectory>false</clearOutputDirectory>

as the default value is true which means before every goal execution, the generated source directory is cleaned. This is not an expected behavior in the case gRPC plugin.