Öncelikle kodda neler yaptığımız bir bakalım. ProtoBuf formatında serileştirme ve ters serileştirme işlemleri için github.com/golang/protobuf/proto paketinde yer alan proto tipinin Marshal ve Unmarshal metodlarından yararlanılıyor. taverna isimli değişken içerisinde iki oyuncu ve bu oyuncuların silahlarına ait test verileri yer almakta. Marshal metodu ile serileştirilen içeriği hem byte array hem de string tipine dönüştürülmüş olarak ekrana bastırmaktayız. Sonrasında da serileştirilmiş bu veri içeriğinden yeni bir Game örneğine ters serileştirme yaparak elde edilen verileri yazdırmaktayız. Çalışma zamanı sonuçları aşağıdaki ekran görüntüsündeki gibidir.
For my team, I'd like to configure maven/eclipse build to automatically generate Java code from *.proto files (in a project that uses gRPC). Currently one needs to run mvn generate-source or mvn protobuf:compile (as in plugin usage page). Or what is the same add Run configuration to invoke maven goal compile.
As I know that should be m2e connector, but I could only find one -protoc-connector for the oldest Googles plugin com.google.protobuf.tools:maven-protoc-plugin, that is even not mentioned currently at -java
Instead of using org.xolstice.maven.plugins:protobuf-maven-plugin my team has used com.github.os72:protoc-jar-maven-plugin to generate the message classes. I believe they are the same since under the hood they all seem to be using the tools from Google.