Protoc integration for Maven. Supports Protoc plugins (such as gRPC), building from descriptors, discovery of sources from the classpath.
See the code
A scratch-built, modern Maven plugin for seamless protoc integration. Features include:
protoc from Maven Central, the system path, or URLsprotoc plugins from binaries on the system path, Maven Central, or from various URLs
protoc plugins that are packaged as regular JARs*.proto sources from your project dependenciesprotocprotoc and any pluginsFull documentation with usage examples can be found within the plugin documentation, and examples are present in the integration tests.
Getting started is very simple. The following will compile any sources that are found in
src/main/protobuf to Java classes and pop them in target/generated-sources where Maven
will automatically discover them and compile them to Java bytecode.
<plugin>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protoc kind="binary-maven">
<version>${protobuf-java.version}</version>
</protoc>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
[!TIP] Any
*.protofiles that are discovered in project dependencies will be made available toprotoc, so you can import them in exactly the same way you would with Java classes!
Other language generation targets are also available. This plugin provides support for generating all the languages that protoc supports out of the box, including Kotlin (JVM), Python, Python typeshed stubs, and Ruby.
The following will generate Java classes and corresponding Kotlin wrappers:
<plugin>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<kotlinEnabled>true</kotlinEnabled>
<protoc kind="binary-maven">
<version>${protobuf-java.version}</version>
</protoc>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
Native Maven dependency management is supported out of the box, allowing you to use Maven as an artifact registry for bundles of Proto files seamlessly.
<project>
...
<dependencies>
<dependency>
<groupId>org.example.protos</groupId>
<artifactId>user-protos</artifactId>
<version>1.2.3</version>
<type>zip</type>
</dependency>
</dependencies>
<plugins>
<plugin>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protoc kind="binary-maven">
<version>${protobuf-java.version}</version>
</protoc>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</project>
The following snippet will compile any protobuf sources in src/main/protobuf to Java source code,
and then proceed to generate gRPC wrappers and Reactor gRPC wrappers.
<plugins>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protoc kind="binary-maven">
<version>${protobuf-java.version}</version>
</protoc>
<plugins>
<!-- Vanilla protoc plugins - these are platform specific executables
just like protoc is. -->
<plugin kind="binary-maven">
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-java</artifactId>
<version>${grpc.version}</version>
</plugin>
<!-- JVM plugins are distributed as JARs rather than native system
executables. The protobuf-maven-plugin will automatically bootstrap
them for you, without the need for additional
tooling for your platform. It should "just work". -->
<plugin kind="jvm-maven">
<groupId>com.salesforce.servicelibs</groupId>
<artifactId>reactor-grpc</artifactId>
<version>${reactor-grpc.version}</version>
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
Java
87.7%
Groovy
10.1%
Shell
1.2%
Protoc integration for Maven. Supports Protoc plugins (such as gRPC), building from descriptors, discovery of sources from the classpath.
See the code
A scratch-built, modern Maven plugin for seamless protoc integration. Features include:
protoc from Maven Central, the system path, or URLsprotoc plugins from binaries on the system path, Maven Central, or from various URLs
protoc plugins that are packaged as regular JARs*.proto sources from your project dependenciesprotocprotoc and any pluginsFull documentation with usage examples can be found within the plugin documentation, and examples are present in the integration tests.
Getting started is very simple. The following will compile any sources that are found in
src/main/protobuf to Java classes and pop them in target/generated-sources where Maven
will automatically discover them and compile them to Java bytecode.
<plugin>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protoc kind="binary-maven">
<version>${protobuf-java.version}</version>
</protoc>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
[!TIP] Any
*.protofiles that are discovered in project dependencies will be made available toprotoc, so you can import them in exactly the same way you would with Java classes!
Other language generation targets are also available. This plugin provides support for generating all the languages that protoc supports out of the box, including Kotlin (JVM), Python, Python typeshed stubs, and Ruby.
The following will generate Java classes and corresponding Kotlin wrappers:
<plugin>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<kotlinEnabled>true</kotlinEnabled>
<protoc kind="binary-maven">
<version>${protobuf-java.version}</version>
</protoc>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
Native Maven dependency management is supported out of the box, allowing you to use Maven as an artifact registry for bundles of Proto files seamlessly.
<project>
...
<dependencies>
<dependency>
<groupId>org.example.protos</groupId>
<artifactId>user-protos</artifactId>
<version>1.2.3</version>
<type>zip</type>
</dependency>
</dependencies>
<plugins>
<plugin>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protoc kind="binary-maven">
<version>${protobuf-java.version}</version>
</protoc>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</project>
The following snippet will compile any protobuf sources in src/main/protobuf to Java source code,
and then proceed to generate gRPC wrappers and Reactor gRPC wrappers.
<plugins>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protoc kind="binary-maven">
<version>${protobuf-java.version}</version>
</protoc>
<plugins>
<!-- Vanilla protoc plugins - these are platform specific executables
just like protoc is. -->
<plugin kind="binary-maven">
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-java</artifactId>
<version>${grpc.version}</version>
</plugin>
<!-- JVM plugins are distributed as JARs rather than native system
executables. The protobuf-maven-plugin will automatically bootstrap
them for you, without the need for additional
tooling for your platform. It should "just work". -->
<plugin kind="jvm-maven">
<groupId>com.salesforce.servicelibs</groupId>
<artifactId>reactor-grpc</artifactId>
<version>${reactor-grpc.version}</version>
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
Java
87.7%
Groovy
10.1%
Shell
1.2%