Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should one start on creating a sbt plugin?

I want to create a sbt plugin for Scala project.

Please any one suggest me how we start?

I referred Plugins documentation but unable to understand steps.

like image 409
Anuj Pratap Singh Avatar asked Feb 05 '13 05:02

Anuj Pratap Singh


1 Answers

The first step in becoming a sbt plugin author is understanding sbt build definition. The best resource for it is Getting Started guide. For plugins, it's essential that you understand the concept of scoping. Some of my blog posts like an unofficial guide to sbt 0.10 v2.0 and traveling through the 4th dimension with sbt 0.13 discuss the topic.

Next, try reading the source code for existing plugins:

  • sbt/sbt-appengine

    • sbt-appengine adds defines appengineSettings, which the build user can include in his or her build definition to add appengineDeploy and other appengine related tasks.
  • sbt/sbt-man

    • sbt-man on the other hand overrides settings and adds man command.

These are roughly two patterns for plugins. Once you understand them fully, try making your own plugin.

Another source of inspiration is the source for sbt itself. Whenever I'm writing a plugin, I'd consult Defaults.scala to see how sbt implements a particular task that I'm interested in. Once you're comfortable, you should also read Plugins Best Practices too.

like image 193
Eugene Yokota Avatar answered Oct 20 '22 22:10

Eugene Yokota