Coder Social home page Coder Social logo

sbt-cppp's Introduction

sbt-cppp

sbt-cppp (Sbt Cross-Project Protobuf Plugin) is a Sbt plugin to support Protocol Buffers, especially in multi-project builds.

Features

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 .proto files.
  • Cross-project protoc include path dependency management in multi-project builds.
  • Cross-library protoc include path dependency management by auto-unzipping .proto files from jar packages.
  • Support for custom code generator to .proto files.

Usage

Step 1: Install sbt-cppp into your project

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"

Step 2: Install protoc into $PATH

For windows, download at http://code.google.com/p/protobuf/downloads/detail?name=protoc-2.5.0-win32.zip. For most linux distributions, looking for protobuf-compiler package.

Step 3: Create your .proto files.

Create src/protobuf/sample_proto.proto

message SampleMessage {
  optional int32 sample_field = 1;
}

Step 4: Use the .proto files in your source files.

Create src/main/scala/SampleMain.scala:

object SampleMain {
  def main(args: Array[String]) {
    println(SampleMessage.newBuilder.setSampleField(123).build)
  }
}

Step 5: Run it!

$ sbt
> run-main SampleMain

Further information

  • sbt-cppp is for sbt 0.12 or 0.13
  • If project-foo depends on project-bar, project-bar/src/protobuf/ will be added as a protoc include path when the plugin converts project-foo/src/protobuf/*.proto into .java files.
  • If you want to generate .proto files by some tools (instead of creating them manually), put sourceGenerators in Protobuf += yourGenerator in your build.sbt.

sbt-cppp's People

Contributors

atry avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.