example of using a custom protoc plugin with gradle

18 views
Skip to first unread message

Jorg Heymans

unread,
Sep 10, 2019, 7:29:54 AM9/10/19
to Protocol Buffers
Hi,

We have created a java plugin to customize the sources protoc generates. It was fairly straightforward to configure this in a maven build but now we have the requirement to add it in a gradle proto project as well. The documentation is a bit sparse (at least for a gradle newbie) on how to do this https://github.com/google/protobuf-gradle-plugin#customize-code-generation-tasks , it seems to assume a good working knowledge of Gradle. So given that we have a jar containing our plugin Main class, how would i set it up in a gradle build ? In maven it looks like this:

                    <protocPlugins>
                        <protocPlugin>
                            <id>CustomProtoPlugin</id>
                            <groupId>a.b.c</groupId>
                            <artifactId>my-plugin</artifactId>
                            <version>1.0</version>
                            <mainClass>CustomPlugin</mainClass>
                            <jvmArgs>
                                <jvmArg>-DprojectProtoSourceDirectory=${project.basedir}/src/main/proto</jvmArg>
                            </jvmArgs>
                        </protocPlugin>
                    </protocPlugins>


Any projects out there that have this working ?

Thanks,
Jorg
Reply all
Reply to author
Forward
0 new messages