dwolla / scrooge-importer   0.3.0

MIT License GitHub

An sbt plugin that simplifies importing thrift files and locally compiling them with scrooge

Scala versions: 2.12
sbt plugins: 1.x

Dwolla Thrift SBT Plugin

A plugin designed to make configuring the build around thrift projects easier.

How to include in a project

Basic Version

Include the scrooge plugin and thrift plugin in the projects plugins.sbt

addSbtPlugin("com.dwolla" % "scrooge-importer" % {version})

This project depends on the scrooge sbt plugin: "com.twitter" % "scrooge-sbt-plugin" % "22.7.0"

Important!: If you use this plugin it will automatically upgrade scrooge to "22.7.0". If you need to use an earlier version, check the troubleshooting section below

It is not necessary to include this in your plugins.sbt, but you may wish to if you need to use a newer version. If you need to use an earlier version, check out the troubleshooting section below.

Tagless scalafix version

There is a separate version that runs this scalafix rule to provide higher-kinded versions of thrift interfaces. You can include it by including this line in your plugins.sbt

addSbtPlugin("com.dwolla" % "scrooge-importer-tagless" % {version})

The scalafix task depends on compile, which means that thrift-clients will compile first and then run the scalafix. If you wish to use the extra code generated by scalafix, then that code must be compiled one more time. As of right now, this is not done automatically because it causes compile to become recursively dependent on itself. We can work around this issue by calling sbt thrift-clients/compile compile

This version depends on this version of scalafix by default "ch.epfl.scala" % "sbt-scalafix" % "0.10.4"

How to use

In the build.sbt file include the following settings on your main project

val root = (project in file("."))
  .settings(
    ...
    ThriftClients / thriftDependencies += "com.dwolla" % "example-thrift" % {version}
  ).dependsOn(ThriftClients)

Troubleshooting

In general, you can take a look at the sbt-test directories in the subprojects to see how to deal with various problems:

Q: I'm stuck on a version of twitter older than 22.7.0. Help!

Example project: core/src/sbt-test/tests/legacyScrooge

You will need to use dependencyOverrides in your plugins.sbt

Q: I'm stuck on an earlier version of scala_2.12/scalafix!

Example project: tagless/src/sbt-test/tests/withOlderScalafix


How it works

The plugin will create a subproject in the directory thrift-clients where it will attempt to import the thrift files and compile them. The thrift-clients subproject can be referenced by the ThriftClients project reference which should be in scope automatically.

You can override these dependencies like any other project, by using ThriftClients / dependencyOverrides