Home

Awesome

sbt-scrooge

sbt-scrooge is an sbt 0.12 plugin that adds support for using scrooge to perform thrift code generation.

The plugin is forked from Twitter's sbt-scrooge repo that is not maintained anymore.

How it works

The plugin registers itself as a source generator for the compile phase.

It fetches scrooge from Ivy2 repository, caches it in your project, and runs it against your thrift folder (usually src/main/thrift). The generated code folder (usually target/src_managed) is then added to your compile path.

Using it

Add following to your project/plugins.sbt file:

resolvers += Resolver.url("Koofr repo", url("https://koofr.github.io/repo/releases/"))

addSbtPlugin("net.koofr" % "sbt-scrooge" % "3.1.1")

And build.sbt:

import net.koofr.sbt._

CompileThriftScrooge.newSettings

name := "yourproject"

organization := "com.example"

version := "1.0.0-SNAPSHOT"

scalaVersion := "2.10.4"

libraryDependencies ++= Seq(
  "org.apache.thrift" % "libthrift" % "0.8.0" intransitive,
  "com.twitter" %% "finagle-core" % "6.2.0",
  "com.twitter" %% "finagle-thrift" % "6.2.0",
  "com.twitter" %% "finagle-ostrich4" % "6.2.0",
  "com.twitter" %% "finagle-redis" % "6.2.0",
  "com.twitter" % "scrooge-runtime" % "3.0.43"
)

CompileThriftScrooge.scroogeBuildOptions := List("--finagle")

Configuration

A full list of settings is in the (only) source file. Here are the ones you're most likely to want to edit:

Notes for helping work on sbt-scrooge

Building

To build the plugin locally and publish it to your local filesystem:

$ sbt publish

To change the publish path add the following to local.sbt:

publishTo := Some(Resolver.file("file", new File("/path/to/maven/")))

Testing

To test the plugin run scripted command in sbt:

$ sbt scripted