Autocompile Protobuf Files

Prerequisites:

Add the plugin,

addSbtPlugin(“com.github.gseitz” % “sbt-protobuf” % “0.6.3”)

to the plugins.sbt under the project[root-build] directory.

Add the following libraries to the build.sbt in the library dependencies: “com.google.protobuf” % “protobuf-java” % (version in ProtobufConfig).value % ProtobufConfig.name, and

“com.googlecode.protobuf-java-format” % “protobuf-java-format” % “1.4”

Next add the following statements out side the library dependencies:

—- Changing the default generated source directory location from ‘src_managed’ in ‘target’ to ‘generated-source’ under ‘app’ directory —-

javaSource in ProtobufConfig := baseDirectory.value / “app” / “generated-source”

— Enable the Protobuf Plugin using the below statement–

enablePlugins(ProtobufPlugin)

Note: Make sure the name of the folder residing *.proto files is ‘protobuf’, since it is the default name to identify the *.proto files location to compile & generate protobuf classes. Finally run the `sbt shell` or `SBTConsole` to clean & compile in order to generate the protobuf classes in “generated-source” directory.

NOTE: Any changes made to the build.sbt file will not take effect until we kill the current process in `sbt shell` or `SBTConsole` & start a new one again.