Plugin.scala
package sbtsample import sbt._ import Keys._ object Plugin extends AutoPlugin { override lazy val projectSettings = Seq(commands += myCommand) lazy val myCommand = Command.command("hello") { (state: State) => println("Hi!") state } }This example demonstrates how to take a Command (here, myCommand) and distribute it in a plugin. Note that multiple commands can be included in one plugin (for example, use commands ++= Seq(a,b)). See Commands for defining more useful commands, including ones that accept arguments and affect the execution state.
For a user to consume this plugin, it requires an explicit include via the Project instance. Here's what their local sbt will look like.
build.sbt
val root = Project("example-plugin-usage", file(".")).setPlugins(MyPlugin)The setPlugins method allows projects to explicitly define the `RootPlugin`s they wish to consume. `AutoPlugin`s are automatically added to the project as appropriate.