英文:
protoc-jar-maven-plugin unable to find dependent proto files in the same directory
问题
我有一个存储所有proto文件的目录,位于${basedir}/resources/proto/
,其中有一个名为a.proto
的文件,它通过resources/proto/b.proto
导入另一个proto文件。我尝试了以下配置,但它的工作方式不如预期:
<plugin>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<version>3.11.4</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputDirectories>
<include>${basedir}/resources/proto</include>
</inputDirectories>
<outputTargets>
<outputTarget>
<type>java</type>
<outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
</outputTarget>
</outputTargets>
</configuration>
</execution>
</executions>
</plugin>
我相当确定includeDirectories
标签只是额外的,不起作用,而我的错误是[ERROR] /home/${basedir}/resources/proto/a.proto [0:0]: resources/proto/b.proto: File not found.
如何正确包含protobuf目录以便进行编译?由于它是一个git子模块,我无法更改proto文件,因此我需要解决当前的情况。
英文:
I have a directory that stores all of my proto files at ${basedir}/resources/proto/
, there is a file a.proto
in which imports another proto file via resources/proto/b.proto
. I tried the following configuration but it does not work as intended:
<plugin>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<version>3.11.4</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputDirectories>
<include>${basedir}/resources/proto</include>
</inputDirectories>
<includeDirectories>
<include>${basedir}/resources/proto</include>
</includeDirectories>
<outputTargets>
<outputTarget>
<type>java</type>
<outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
</outputTarget>
</outputTargets>
</configuration>
</execution>
</executions>
</plugin>
I'm pretty sure the includeDirectories tag is just extra and does nothing, and my error is [ERROR] /home/${basedir}/resources/proto/a.proto [0:0]: resources/proto/b.proto: File not found.
How can I properly include the protobuf directories so it can compile? I cannot change the proto files as it is a git submodule therefore I need to work around the current situation.
答案1
得分: 1
已解决,包含目录需要直接包含基本目录,因为 Protobuf 文件试图通过完整路径来发现它们。
英文:
Figured it out, include directory needs to directly include the basedir as the protobuf files tries to discover them through the full path.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论