Protobuf for lazy Java coders.

Sometimes you are just plain lazy and would rather have Maven create the Java files out of .proto. The alternative would have been to download the protoc, fire up the terminal and issue one simple command. Not a big deal at all. But as I said sometimes you are just plain lazy.

So how do you go about it. Follow the steps given below.

Think up a super critical message that you want to send across over the wire.
If you dont know how to write a .proto file, perhaps one of the links below would help.
https://developers.google.com/protocol-buffers/docs/proto
https://developers.google.com/protocol-buffers/docs/proto3
The one below is the super critical hello world that I want to send across.

#1

Create a vanilla maven project. 
Say thanks to open source and add protoc-jar-maven-plugin to the project. 

#2

This would create the java files.
However they will complain that the google libraries are not around. 
So you will have to add the protobuf libraries. 

#3

The proof of the pudding is in eating it. 
Let's write a test to serialize and deserialize the super critical message. 

#4

That's it. You have a Java project that does the basic steps i.e. serialization / deserialization using protobuf. Hope that is helpful. If you know a easier, quicker way please share as well. 

Either ways your comments will be appreciated. Please take a couple of minutes and write back.