Joachim Hofer is a long-time senior consultant and lead developer on the Java platform who has recently become a fan of Scala. He regularly contributes to Open Source community projects and shares his experience in his blog and talks. Joachim is a DZone MVB and is not an employee of DZone and has posted 12 posts at DZone. You can read more from them at their website. View Full User Profile

A few short notes on converting SBT plugins to 0.10.x

06.10.2011
| 3729 views |
  • submit to reddit

I just finished converting my FindBugs SBT plugin findbugs4sbt to SBT 0.10.x.

FindBugs? What’s that? – Go have a look at its website, and then use it, always! One caveat though: It doesn’t support Scala source code. So use it with all your Java projects.

SBT? What’s that? – It’s a Scala-based build tool called “Simple Build Tool”, and it’s cool. Have a look at it and try it out!

Anyway, if you already know about SBT and think about moving over to the new 0.10.x version, or if you even think about hacking your own plugin for it (please do!), the following quick notes may be of interest to you…

  • Read the SBT wiki page about plugins first. It’s not perfect, but it’s a good start, and you could always help improving it.
  • SBT 0.10.x has changed so much that it’s a rewrite, mostly. Give up your hope of “simply converting” your plugin.
  • However, the new settings system seems well thought-out. Forget the trait- and override-based system of 0.7.x. You know you want to.
  • You want to take a look at this SBT source file. Believe me. You just don’t know yet that you do. Knowing the settings keys is absolutely vital for hacking plugins.
  • Take a good long look at all the existing plugins‘ source code. They’re all doing different things in different ways, and all in all, there’s a lot to learn from them.
  • Quick, learn the difference between SBT tasks and commands. In my humble opinion, task plugins are probably easier to write than command plugins.
  • Don’t be afraid to read and ask questions in the SBT Google Group.
  • Don’t use SBT 0.9.9. It’s the one slow version of SBT, and I used it for most of my plugin conversion, so that you don’t have to, too. :)
  • Please don’t put everything into one plugin source file. There are other people out there who want to learn how to create their own SBT plugins, and they want to be able to read and understand your code.
  • Browse the SBT API documentation and use the stuff that’s already in there. It’s a lot, even if it’s perhaps not so easy to find your way around in there (at least it hasn’t been for me).
  • Maybe, you want to consider comparing the sbt-0.7.x and the default branch of my findbugs4sbt plugin, if you want to convert something task-based and are after a “before” vs “after” comparison.

So there you have it, a few of my insignificant and unordered plugin conversion impressions. I hope you’ve had fun reading them.

 

From http://jmhofer.johoop.de/?p=210

Published at DZone with permission of Joachim Hofer, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Sirikant Noori replied on Sat, 2012/03/31 - 2:39pm

“Please don’t put everything into one plugin source file.” <
m + ” But in my case (sbteclipse) I really needed the locality of the state argument. No fun adding it to a lot of methods. Therefore I went for a single-method with local methods approach. Only works for one file, though.”

jsp

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.