xolstice / protobuf-maven-plugin

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

Allow for custom plugins to be supplied to the main invocation of pro… #67

Open dpratt opened 5 years ago

dpratt commented 5 years ago

…toc.

The protobuf plugin does not allow for custom plugins to be supplied to a single protoc that includes the main java stub generation. This ends up being a problem for plugins that utilize features like protobuf's extension point support, since they rely on protoc to supply info about where it's main phase has emitted Java code.

Instead of relying on the compile-custom goal to execute a new, distinct follow-on execution of protoc, allow for elements in the configuration of the main compile task to augment the arguments passed to protoc. For example, after this commit, you can do the following

      <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>0.7.0-SNAPSHOT</version>
        <configuration>
          <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
          <protocPlugins>
            <plugin>
              <id>grpc-java</id>
              <groupId>io.grpc</groupId>
              <artifactId>protoc-gen-grpc-java</artifactId>
              <version>${grpc.version}</version>
              <type>exe</type>
              <classifier>${os.detected.classifier}</classifier>
            </plugin>
            <plugin>
              <id>kotlin</id>
              <groupId>com.github.marcoferrer.krotoplus</groupId>
              <artifactId>protoc-gen-kroto-plus</artifactId>
              <version>${kroto-plus.version}</version>
              <classifier>jvm8</classifier>
            </plugin>
          </protocPlugins>
        </configuration>
        <executions>
          <execution><goals><goal>compile</goal></goals></execution>
        </executions>
      </plugin>

With the above configuration, maven generates and executes a command line that looks like

protoc --java_out=... --plugin=protoc-gen-grpc-java --grpc-java_out=... --plugin=protoc-gen-kroto-plus --kroto-plus_out=...

which allows for plugins to have full access to the entire protoc generation context.

skjolber commented 4 years ago

@sergei-ivanov any hope for this? We're currently using this feature, and it would be helpful having it released.

seime commented 3 years ago

@sergei-ivanov, I see no release since October 2018, almost 2.5 years ago. Do you intend to continue your excellent work, or have you moved on to other projects taking all your time - and this fork can be considered dead?

Regards