|
SbtPlugins
sbt has movedsbt has now completely moved to GitHub. See https://github.com/harrah/xsbt/wiki/Plugins.
Existing Plugins
See Integration Support for IDE-related plugins. See also the complementary extension mechanism Processors, which includes a list of existing processors. BasicsPlugins are libraries for your project definition. Declare them like dependencies for your project, except in a plugin definition in the project/plugins/ directory. For example, to use MarkdownJ in your project definition, create: project/plugins/Plugins.scala import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info)
{
val a = "org.markdownj" % "markdownj" % "0.3.0-1.0.2b4"
}Verify it is correct by doing reload and then console-project. Call some MarkdownJ code: scala> new com.petebevin.markdown.MarkdownProcessor res1: com.petebevin.markdown.MarkdownProcessor = Markdown Processor for Java 0.3.0 (compatible with Markdown 1.0.2b2) This dependency was independent of sbt. You can also create and use plugins that extend or use sbt. The rest of this page describes sbt plugins. The first part shows the results of a plugin that creates a self-extracting jar out of a project. The second part shows how to create a simple plugin that provides a new action to a project. Hello Lift Installer Example
Hello World PluginTo try out plugins, we'll make a simple hello world plugin and use it. Make the PluginTo make a plugin, create a new project with a project definition that extends PluginProject. This can now go in project/build. The basic example: import sbt._ class TestPluginProject(info: ProjectInfo) extends PluginProject(info) Make a simple plugin by putting the following in src/main/scala : package hw
import sbt._
trait HelloWorldPlugin extends Project {
lazy val hello = task { log.info("Hello World!"); None }
}Publish it by running the publish-local action. Use the PluginTo use the plugin, create a new project. Declare plugins by putting a plugin definition (basically a project definition that extends PluginDefinition) in project/plugins/. The following example assumes that the plugin above had was setup with the name "test" and with version "1.0". import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val a = "test" % "test" % "1.0"
}Define the project definition in project/build/ to use the HelloWorldPlugin : import sbt._ class TestProject(info: ProjectInfo) extends DefaultProject(info) with hw.HelloWorldPlugin Try it out by running the hello action at the prompt. Detailssbt plugins are a way to reuse code between project definitions. They can consist of any Scala code you want. Specifically, they are not restricted to providing a single trait extending Project, as in the example. You can provide a trait that extends Project, DefaultProject, or DefaultWebProject that the user then mixes in to use. You can provide multiple project types or you can just provide code that can be used to implement tasks. See the Existing Plugins section at the top of the page for examples of plugins. Installer PluginThe installer plugin provides a task 'installer' that creates a self-executable jar that bundles the current project. When executed, the jar will extract the sbt launcher and the project, run sbt on the project, and execute predefined commands. To use it, first declare the plugin: project/plugins/Plugins.scala
Then, mix the BasicSelfExtractingProject trait into your build definition: project/build/YourProject.scala
Overriding installActions is optional. It defines the actions that sbt runs after the project is extracted. By default, 'update' and 'compile' are run. Finally, create the self-extracting jar by running the installer action on the project. The resulting jar can be run with java -jar .... The installer project is a subproject of sbt in the sbt/install/ directory. | |
I would appreciate putting a link to bnd4sbt on this page ... http://github.com/weiglewilczek/bnd4sbt
Added, thanks!
Mark, here's another good plugin for your list: http://github.com/markchadwick/jython-sbt-plugin
Thanks, Brian. I added it.
Could you add sbt-eclipsify plugin to the list http://github.com/musk/SbtEclipsify
I added a link to IntegrationSupport, where you are already listed. If you'd like the section there expanded, please feel free to comment on that page.
Maybe you'd like to add findbugs4sbt to the list, too? - see http://bitbucket.org/jmhofer/findbugs4sbt
Added, thanks!
I've now created a plug-in for the Copy/Paste Detector (CPD) of PMD, too. - Could you add that one, too, please? - see http://bitbucket.org/jmhofer/cpd4sbt
Added, thanks.
Would it be possible to add a link here to the sbt-coverage (undercover code coverage tool) processor? I know it's not a plugin, but I imagine that most people will look on this page for plugin like things! It's at http://github.com/sroebuck/sbt-coverage
I added it to the Processors page, which is now linked to from this page and DocumentationHome
I've just made a new plugin for SBT that does resource filtering. Do you mind spreading the word?
https://bitbucket.org/wyuenho/sbt-filter-plugin
Thanks!
I added the link and you can certainly send an announcement to the list if you want.