Giriş
protobuf için birkaç tane plugin var. Sanırım en çok kullanılanı bu.
Goals
Şöyle
compile
compile-custom
Her iki goal da kullanılmalı
Ayarlar
Bu kısımlar her zaman şöyle
Ortak Ayarlar
protocArtifact : com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}
compile Ayarları
pluginId : grpc-java
compile-custom Ayarları
pluginArtifact : io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
Ayrıca şu dependency de lazım
<dependency><groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> <version>3.12.2</version> </dependency>
Bu plugini kullanabilmek için şu lazım
<build> <!-- protobuf extension--> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> <version>1.7.1</version> </extension> </extensions> ... </build>
compile goal
Tam hali şöyle
<build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> <version>1.7.1</version> </extension> </extensions> <plugins> <plugin> <groupId>org.xolstice.maven.plugins</groupId> <artifactId>protobuf-maven-plugin</artifactId> <version>${protobuf-plugin.version}</version> <configuration> <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact> <pluginId>grpc-java</pluginId> <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact> </configuration> <executions> <execution> <goals> <goal>compile</goal> <goal>compile-custom</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
Örnek
Şöyle yaparız
<plugin> <groupId>org.xolstice.maven.plugins</groupId> <artifactId>protobuf-maven-plugin</artifactId> <version>0.6.1</version> <configuration> <protocArtifact> com.google.protobuf:protoc:3.21.7:exe:${os.detected.classifier} </protocArtifact> <pluginId>grpc-java</pluginId> <pluginArtifact> io.grpc:protoc-gen-grpc-java:1.52.1:exe:${os.detected.classifier} </pluginArtifact> </configuration> <executions> <execution> <goals> <goal>compile</goal> <goal>compile-custom</goal> </goals> </execution> </executions> </plugin>
Örnek
Şöyle yaparız
<plugin><groupId>org.xolstice.maven.plugins</groupId><artifactId>protobuf-maven-plugin</artifactId><version>0.5.1</version><configuration><protocArtifact>com.google.protobuf:protoc:3.6.1:exe:${os.detected.classifier}</protocArtifact><pluginId>grpc-java</pluginId><pluginArtifact>io.grpc:protoc-gen-grpc-java:1.22.1:exe:${os.detected.classifier}</pluginArtifact><protoSourceRoot>${basedir}/src/main/proto/</protoSourceRoot></configuration><executions><execution><goals><goal>compile</goal><goal>compile-custom</goal></goals></execution></executions></plugin>
compile-custom Goal
Örnek
proto dosyalarından dokümantasyon üretmek için şu eklentiler kullanılabilir.
protoc-gen-doc
gRPC-docs
GenDocu Cloud
Buf
protoc-gen-doc kullanmak için şöyle yaparız. Burada hem compile hem de compile-custom goal belirtiliyor. Ancak compile-custom iki defa belirtiliyor. İkinci belirtimde protoc-gen-doc plugin kullanılarak dokümantasyon üretmesi isteniyor
<plugin> <groupId>org.xolstice.maven.plugins</groupId> <artifactId>protobuf-maven-plugin</artifactId> <version>0.6.1</version> <configuration> <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier} </protocArtifact> </configuration> <executions> <execution> <id>protoc-java</id> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>protoc-grpc</id> <goals> <goal>compile-custom</goal> </goals> <configuration> <pluginId>grpc-java</pluginId> <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} </pluginArtifact> </configuration> </execution> <execution> <id>protoc-doc</id> <goals> <goal>compile-custom</goal> </goals> <configuration> <pluginId>doc</pluginId> <pluginArtifact> io.github.pseudomuto:protoc-gen-doc:${protoc-gen-doc.version}:exe:${os.detected.classifier} </pluginArtifact> <pluginParameter>markdown,grpc-api.md</pluginParameter> </configuration> </execution> </executions> </plugin> </plugins> </build>
Hiç yorum yok:
Yorum Gönder