Auto-configure *.proto paths from project dependencies
See original GitHub issueI have a project, using Kotlin/Gradle that has the following dependency:
implementation("com.google.api.grpc:proto-google-common-protos:1.16.0")
if I configure the path to the sources jar file in the Preferences --> Protocol Buffers as:
jar:///<…PATH TO HOME>/.gradle/caches/modules-2/files-2.1/com.google.api.grpc/proto-google-common-protos/1.16.0/bdc28414cdd1f5003c2fdcc59c7f597c2da5b1b1/proto-google-common-protos-1.16.0-sources.jar!/
The Plug-In finds the proto files and correctly resolves the imports.
Is there a way to have the plug-in pick up protofiles from the Gradle dependencies (or IntelliJ project libraries) using “AutoConfigure”?
The option to manually configure will not quite work as it requires the local path to the jar file, and that changes from developer to developer.
Any ideas would be most welcome.
Miguel
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5
Top GitHub Comments
First of all: Great plugin! It would be even better with some minor adjustments to the automatic configuration for import paths. While the plugin could scan dependencies for protos as suggested by @jmpicnic an easier fix would be to automatically add
target/classes
,target/test-classes
andtarget/protoc-dependencies/*
to the path (perhaps instead ofsrc/main/resources and src/test/resources
). This provides more flexibility for the user.For example, we use the
org.xolstice.maven.plugins:protobuf-maven-plugin
. Out of the box this plugin scans for protos under src/main/proto and not under src/main/resources. However, all compiled protos are placed undertarget/classes
.The
protobuf-maven-plugin
also extracts all protofiles from dependencies and places them undertarget/protoc-dependencies
. In the default format of this directory (there are two formats) proto files in jars are extracted into a directory named after a hash of the jar-file coordinates. For example, in my project I have:Which corresponds to
com.google.api.grpc:proto-google-common-protos:jar:1.17.0
andcom.google.protobuf:protobuf-java:jar:3.13.0
. The plugin could automatically add these directories too.What do you think?
@jvolkman said he will refactor the file resolver, but there are no updates after many months.
I really need this feature for our team, so I built a new plugin for improving development experience with protobuf for Java Project.
And I just make the plugin public now, if you use the protos in Jar same as me, you can try this plugin.