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

use pluginArtifact and pluginExecutable #31

Closed jorgheymans closed 6 years ago

jorgheymans commented 6 years ago

Hi,

I have a few proto's with grpc service definitions in them for which i would like to generate documentation using this plugin https://github.com/pseudomuto/protoc-gen-doc.

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

I was hoping to generate the grpc classes and documentation in one go, but it does not work. The grpc class generation is skipped when i put the pluginExecutable for protoc-gen-doc. Is there a way to make this work ?

sergei-ivanov commented 6 years ago

Hi,

You may need to define separate executions for each of the protoc plugins. I would generally recommend running compile and compile-custom goals in separate executions, so that each of the executions can have its own configuration. Some of the configuration options may be mutually exclusive, such as pluginArtifact and pluginExecutable in your case .

Can you please try it this way (I haven't tested it, but should work):

      <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>0.5.0</version>
        <configuration>
          <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
        </configuration>
        <executions>
          <execution>
            <id>protoc-java</id>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>protoc-grpc</id>
            <goals>
              <goal>compile-custom</goal>
            </goals>
            <configuration>
              <pluginId>grpc-java</pluginId>
              <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
            </configuration>
          </execution>
          <execution>
            <id>protoc-doc</id>
            <goals>
              <goal>compile-custom</goal>
            </goals>
            <configuration>
              <pluginId>doc</pluginId>
              <pluginExecutable>C:/RC/tmp/protoc-gen-doc.exe</pluginExecutable>
              <pluginParameter>html,index.html</pluginParameter>
            </configuration>
          </execution>
        </executions>
      </plugin>
jorgheymans commented 6 years ago

cool that worked perfectly, thanks for you reply !