https://github.com/dwolla/scrooge-importer
An sbt plugin that simplifies importing thrift files and locally compiling them with scrooge
https://github.com/dwolla/scrooge-importer
Last synced: about 2 months ago
JSON representation
An sbt plugin that simplifies importing thrift files and locally compiling them with scrooge
- Host: GitHub
- URL: https://github.com/dwolla/scrooge-importer
- Owner: Dwolla
- License: mit
- Created: 2023-04-28T19:11:26.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-17T21:42:54.000Z (almost 2 years ago)
- Last Synced: 2025-02-15T23:43:59.579Z (4 months ago)
- Language: Scala
- Size: 18.6 KB
- Stars: 1
- Watchers: 11
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dwolla Thrift SBT Plugin
A plugin designed to make configuring the build around thrift projects easier.
## How to include in a project
### Basic VersionInclude the scrooge plugin and thrift plugin in the projects `plugins.sbt`
```scala
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 belowIt 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](https://github.com/Dwolla/async-utils-twitter) to provide higher-kinded versions of thrift interfaces.
You can include it by including this line in your `plugins.sbt`
```scala
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 useIn the `build.sbt` file include the following settings on your main project
```scala
val root = (project in file("."))
.settings(
...
ThriftClients / thriftDependencies += "com.dwolla" % "example-thrift" % {version}
).dependsOn(ThriftClients)
```
## TroubleshootingIn 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`