sbt-cppp (Sbt Cross-Project Protobuf Plugin) is a Sbt plugin to support Protocol Buffers, especially in multi-project builds.
sbt-cppp compiles *.proto into .java files. In addition, sbt-cppp provides some features missed in sbt-protobuf or other protobuf plugins:
- Jar packaging from 
.protofiles. - Cross-project 
protocinclude path dependency management in multi-project builds. - Cross-library 
protocinclude path dependency management by auto-unzipping.protofiles from jar packages. - Support for custom code generator to 
.protofiles. 
Add the following line to your project/plugins.sbt:
addSbtPlugin("com.dongxiguo" % "sbt-cppp" % "0.1.4")
And add protobufSettings and protobuf-java dependency to your build.sbt:
protobufSettings
libraryDependencies += "com.google.protobuf" % "protobuf-java" % "2.5.0"
For windows, download at http://code.google.com/p/protobuf/downloads/detail?name=protoc-2.5.0-win32.zip. For most linux distributions, look for protobuf-compiler package.
Create src/protobuf/sample_proto.proto
message SampleMessage {
  optional int32 sample_field = 1;
}
Create src/main/scala/SampleMain.scala:
object SampleMain {
  def main(args: Array[String]) {
    println(SampleMessage.newBuilder.setSampleField(123).build)
  }
}
$ sbt
> run-main SampleMain
sbt-cpppis for sbt 0.12 or 0.13- If 
project-foodepends onproject-bar,project-bar/src/protobuf/will be added as aprotocinclude path when the plugin convertsproject-foo/src/protobuf/*.protointo.javafiles. - If you want to generate 
.protofiles by some tools (instead of creating them manually), putsourceGenerators in Protobuf += yourGeneratorin yourbuild.sbt.