Packages

c

sbt

AutoPlugin

abstract class AutoPlugin extends Basic with PluginsFunctions

An AutoPlugin defines a group of settings and the conditions where the settings are automatically added to a build (called "activation"). The requires and trigger methods together define the conditions, and a method like projectSettings defines the settings to add.

Steps for plugin authors:

  1. Determine if the AutoPlugin should automatically be activated when all requirements are met, or should be opt-in.
  2. Determine the AutoPlugins that, when present (or absent), act as the requirements for the AutoPlugin.
  3. Determine the settings/configurations to that the AutoPlugin injects when activated.
  4. Determine the keys and other names to be automatically imported to *.sbt scripts.

For example, the following will automatically add the settings in projectSettings to a project that has both the Web and Javascript plugins enabled.

object MyPlugin extends sbt.AutoPlugin {
  override def requires = Web && Javascript
  override def trigger = allRequirements
  override def projectSettings = Seq(...)

  object autoImport {
    lazy val obfuscate = taskKey[Seq[File]]("Obfuscates the source.")
  }
}

Steps for users:

  1. Add dependencies on plugins in project/plugins.sbt as usual with addSbtPlugin
  2. Add key plugins to projects, which will automatically select the plugin + dependent plugin settings to add for those projects.
  3. Exclude plugins, if desired.

For example, given plugins Web and Javascript (perhaps provided by plugins added with addSbtPlugin),

myProject.enablePlugins(Web && Javascript)

will activate MyPlugin defined above and have its settings automatically added. If the user instead defines

myProject.enablePlugins(Web && Javascript).disablePlugins(MyPlugin)

then the MyPlugin settings (and anything that activates only when MyPlugin is activated) will not be added.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AutoPlugin
  2. PluginsFunctions
  3. Basic
  4. Plugins
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new AutoPlugin()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def &&(o: Basic): Plugins
    Definition Classes
    BasicPlugins
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def allRequirements: PluginTrigger

    This plugin is activated when all required plugins are present.

    This plugin is activated when all required plugins are present.

    Definition Classes
    PluginsFunctions
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def buildSettings: Seq[Def.Setting[_]]

    The Setting to add to the build scope for each project that activates this AutoPlugin.

    The Setting to add to the build scope for each project that activates this AutoPlugin. The settings returned here are guaranteed to be added to a given build scope only once regardless of how many projects for that build activate this AutoPlugin.

  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  9. def derivedProjects(proj: ProjectDefinition[_]): Seq[Project]

    The Projects to add to the current build based on an existing project.

  10. def empty: Plugins

    Plugins instance that doesn't require any Pluginss.

    Plugins instance that doesn't require any Pluginss.

    Definition Classes
    PluginsFunctions
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. def extraProjects: Seq[Project]

    The Projects to add to the current build.

  14. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def globalSettings: Seq[Def.Setting[_]]

    The Settings to add to the global scope exactly once if any project activates this AutoPlugin.

  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. val label: String
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. def noTrigger: PluginTrigger

    This plugin is activated only when it is manually activated.

    This plugin is activated only when it is manually activated.

    Definition Classes
    PluginsFunctions
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. def projectConfigurations: Seq[Configuration]

    The Configurations to add to each project that activates this AutoPlugin.

  25. def projectSettings: Seq[Def.Setting[_]]

    The Settings to add in the scope of each project that activates this AutoPlugin.

  26. def requires: Plugins

    This AutoPlugin requires the plugins the Plugins matcher returned by this method.

    This AutoPlugin requires the plugins the Plugins matcher returned by this method. See trigger.

  27. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  28. def toString(): String
    Definition Classes
    AutoPlugin → AnyRef → Any
  29. def trigger: PluginTrigger

    Determines whether this AutoPlugin will be activated for this project when the requires clause is satisfied.

    Determines whether this AutoPlugin will be activated for this project when the requires clause is satisfied.

    When this method returns allRequirements, and requires method returns Web && Javascript, this plugin instance will be added automatically if the Web and Javascript plugins are enabled.

    When this method returns noTrigger, and requires method returns Web && Javascript, this plugin instance will be added only if the build user enables it, but it will automatically add both Web and Javascript.

  30. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from PluginsFunctions

Inherited from Basic

Inherited from Plugins

Inherited from AnyRef

Inherited from Any

Ungrouped