Jacek Laskowski
Jacek Laskowski

Reputation: 74679

How to know available tasks and settings of installed plugin in sbt?

Given the following setup with the sbt-git plugin:

> about
[info] This is sbt 0.13.2
[info] The current project is {file:/Users/jacek/oss/sbt-git/}sbt-git 0.6.4-SNAPSHOT
[info] The current project is built against Scala 2.10.3
[info] Available Plugins: com.typesafe.sbt.SbtGit
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.3

How can I query for the available tasks and settings of the plugin? I'd like to be able to say - show tasks and settings of a plugin - on the sbt shell. Possible? How?

Upvotes: 5

Views: 1592

Answers (2)

Havoc P
Havoc P

Reputation: 8467

The trick here is that plugins are just jars and tasks and settings are just Java/Scala values. So literally any method in the plugin jar can return tasks and settings. All sbt knows about are the settings and tasks you have added to your project. But to add them you have to know about the methods and fields to get settings from.

Right now the docs and source of the plugin are how you'd find what you can add. Usually the README is a good starting point.

Current sbt has one magic method on plugin objects called "settings" which contains settings to auto-add to all projects. However, the plugin guidelines advise against using this feature because plugins have no way to know whether their settings make sense for every project in a build. So many plugins don't use it.

In an upcoming sbt release there's a new AutoPlugin feature which solves this and allows plugins to auto-add themselves only to projects with certain features. For example a plugin might only add itself to Java projects or only to Play projects.

Still, you would only be able to query sbt for settings which were added, rather than for all available settings.

Upvotes: 0

Eugene Yokota
Eugene Yokota

Reputation: 95624

How can I query for the available tasks and settings of the plugin?

It's not specific to a plugin, but try typing tasks and settings from the shell. It should be a relatively short list that you can fish things out.

Upvotes: 2

Related Questions