Writing sbt 0.10.x plugins (converting findbugs4sbt)

58 views
Skip to the first unread message

Joachim Hofer

unread,
7 Jun 2011, 3:02:43 pm07/06/2011
to simple-build-tool
Hi,

I've just converted my FindBugs sbt plugin from sbt 0.7.x to sbt
0.10.x by looking at the existing plugins referenced in the sbt wiki,
and also by reading the wiki (and the sbt source, sometimes). - Now,
my initial tests show that the plugin should work.

However, I'm still not sure at all if what I did is the correct way to
write a plugin for the new sbt... - so I'd appreciate a lot if anyone
could perhaps take a look at my code and tell me what's good and
what's bad, or what's "idiomatic" for sbt 0.10.x and what's plain
stupid... - I've got a feeling that I've done a few stupid things
because I don't know the new sbt well enough yet. For example, the
error handling in my command line executor looks like a hack. How
should tasks do their error handling?

Also: Should I use packages for my classes at all?

I already know that tests against my plugin are missing: I'm not sure
how to best test more than a few trivial things concerning my plugin.
However, I haven't yet looked at how other plugin coders do their
testing.

My plugin adds a task named "findbugs" which calls the FindBugs static
code analysis (only useful for Java code, of course). This task has a
few settings, like the output path for the results, or how to format
the FindBugs report. - You can find it at https://bitbucket.org/jmhofer/findbugs4sbt

Thanks in advance for any input!

Cheers,
Joachim

Mark Harrah

unread,
7 Jun 2011, 10:16:20 pm07/06/2011
to simple-b...@googlegroups.com
On Tue, 7 Jun 2011 12:02:43 -0700 (PDT)
Joachim Hofer <jmhofer...@johoop.de> wrote:

> Hi,
>
> I've just converted my FindBugs sbt plugin from sbt 0.7.x to sbt
> 0.10.x by looking at the existing plugins referenced in the sbt wiki,
> and also by reading the wiki (and the sbt source, sometimes). - Now,
> my initial tests show that the plugin should work.
>
> However, I'm still not sure at all if what I did is the correct way to
> write a plugin for the new sbt... - so I'd appreciate a lot if anyone
> could perhaps take a look at my code and tell me what's good and
> what's bad, or what's "idiomatic" for sbt 0.10.x and what's plain
> stupid... - I've got a feeling that I've done a few stupid things
> because I don't know the new sbt well enough yet. For example, the
> error handling in my command line executor looks like a hack. How
> should tasks do their error handling?

Sure, I'll take a look, but it might be a for a few days. Remind me if you don't hear back in the next week.

> Also: Should I use packages for my classes at all?

Yes. Think of plugins as libraries for your build.

> I already know that tests against my plugin are missing: I'm not sure
> how to best test more than a few trivial things concerning my plugin.
> However, I haven't yet looked at how other plugin coders do their
> testing.

Generally, the scripted plugin is the easiest, although it is more functional testing than unit testing. You can see how Artyom does it in the web plugin:

https://github.com/siasia/xsbt-web-plugin/

> My plugin adds a task named "findbugs" which calls the FindBugs static
> code analysis (only useful for Java code, of course). This task has a
> few settings, like the output path for the results, or how to format
> the FindBugs report. - You can find it at https://bitbucket.org/jmhofer/findbugs4sbt
>
> Thanks in advance for any input!

I didn't see you link to your writeup here, so I'll add it:

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

I'll try to remember to add some comments there as well when I get a chance.

-Mark

Keith Irwin

unread,
8 Jun 2011, 1:04:29 pm08/06/2011
to simple-b...@googlegroups.com
Hey, thanks for putting this out there. It helped me figure a few things out that I couldn't get from the docs.

Joachim Hofer

unread,
9 Jun 2011, 12:04:34 pm09/06/2011
to simple-build-tool
> Generally, the scripted plugin is the easiest, although it is more functional testing than unit testing.  You can see how Artyom does it in the web plugin:
>
> https://github.com/siasia/xsbt-web-plugin/

Thanks, the scripted-plugin looks like it is exactly what I was
looking for for testing findbugs4sbt. I'll try it out and see how it
goes.

Cheers
Joachim
Reply all
Reply to author
Forward
0 new messages