Skip to content

SBT Plugin for compiling Thrift. Adopted after upstream project was archived.

License

Notifications You must be signed in to change notification settings

integrated-application-development/sbt-thrift-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SBT Thrift Plugin

Forked from intenthq/sbt-thrift-plugin@0a59b40.

A Thrift plugin for compiling Thrift sources into Java and adding the generated classes into the compile scope automagically.

In addition to Java, this plugin can also compile to the following languages:

  • Javascript
  • Ruby
  • Python
  • Delphi

These aren't supported as sources by SBT but will be available in a target/gen-<lang> directory for use by yourself in any suitable way you can think of.

By default, the plugin will compile to Java only. See the settings section below for details on how to enable other languages.

Usage

This is an SBT auto-plugin so all you have to do is add the following to your project/plugins.sbt:

addSbtPlugin("au.com.integradev.sbt" % "sbt-thrift-plugin" % "1.1.0")

Installing Thrift

This plugin depends on having the thrift binary in your PATH — it does not add any speciifc dependency on libthrift for you. This means you should:

  • Make sure the correct version of thrift you need is installed on your system and in your PATH.
  • Make sure you add a dependency on the correct version of libthrift to the application.

Settings

To set any settings, you'll need to import the settings into your build.sbt:

import au.com.integradev.sbt.ThriftPlugin._

The following languages are supported by this plugin:

  • Java
  • Javascript (referred to in setting names as Js)
  • Ruby
  • Python
  • Delphi

For all of these languages, the following SBT settings are available (where <lang> is the name of the language above):

  • thrift<lang>Enabled: Whether to enable generation of code for this language. Defaults to true for Java, false for all other languages.
  • thrift<lang>Options: Options to pass the Thrift compiler when generating the source files. See thrift -help for the optional available for your chosen language. Defaults to an empty set of options for all languages.
  • thrift<lang>OutputDir: The directory to save the generated files into. Defaults to target/gen-<lang>.
  • thriftGenerate<lang> / thriftPostProcessor: A transform function to post-process each generated file during thriftGenerate<lang> after the main thrift generation command has finished.
  • thriftGenerate<lang> / thriftCompileGeneratedSources: Whether to compile the files generated by thriftGenerate<lang> in this build's compile task.

All languages have a task, thriftGenerate<lang>, to generate the files manually. This task will automatically be run by SBT when running compile, as it is added as an SBT source generator.

Acknowledgements

The code for this plugin was adapted from intenthq/sbt-thrift-plugin@0a59b40 which in turn was adapted from the following source.

About

SBT Plugin for compiling Thrift. Adopted after upstream project was archived.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 98.5%
  • Thrift 1.5%