Reputation: 81
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.
Upvotes: 7
Views: 2416
Reputation: 95624
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-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-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.
Upvotes: 5