Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dpratt
Copy link

@dpratt dpratt commented Aug 29, 2019

…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.

@dpratt dpratt force-pushed the dpratt/extended-plugin-support branch from f9a5d2e to e70d33d Compare August 29, 2019 20:05
…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 <plugin> 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.
@dpratt dpratt force-pushed the dpratt/extended-plugin-support branch from e70d33d to d5d37a4 Compare February 3, 2020 22:16
@skjolber
Copy link

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

@seime
Copy link

seime commented Feb 8, 2021

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants