在 Eclipse IDE 中使用 maven/m2e 从 .proto 自动生成 Java
对于我的团队,我想将maven/eclipse构建配置为从文件自动生成Java代码(在使用gRPC的项目中)。目前需要运行或(如插件使用页面)。或者是什么相同的添加运行配置来调用maven目标。*.proto
mvn generate-source
mvn protobuf:compile
compile
每当 Eclipse Maven 项目刷新 (+) 或重新启动 IDE 时,都会重新生成项目,但没有应出现在 中的内容,从而将项目转换为红色。因此,需要生成并刷新项目()。更新 Eclipse 需要在文件中配置的源文件夹。AltF5target/generated
F5.clathpath
据我所知,这应该是m2e连接器,但我只能找到一个最古老的Google https://github.com/masterzen/m2e-protoc-connector,目前甚至没有提到 https://github.com/grpc/grpc-javas plugin com.google.protobuf.tools:maven-protoc-plugin
我们使用精确引用/推荐
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
那是:
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.1.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.1.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
相关:
- 链接到 Eclipse 中生成的 Java 原型代码
- 看了这个,但那个作者使用的是其他较旧的,现在不支持的插件:Eclipse构建循环由protobuf生成的代码引起(与Maven Project Builder相关)
P.P.S 该插件 https://github.com/igor-petruk/protobuf-maven-plugin 但是具有延续性 https://github.com/os72/protoc-jar-maven-plugin