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
Known Subclasses
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
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new AutoPlugin()

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def &&(o: Basic): Plugins

    Definition Classes
    BasicPlugins
  5. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  6. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  7. 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
  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def buildSettings: Seq[Def.Setting[_]]

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

    The Settings 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.

  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def derivedProjects(proj: ProjectDefinition[_]): Seq[Project]

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

  12. def empty: Plugins

    Plugins instance that doesn't require any Pluginss.

    Plugins instance that doesn't require any Pluginss.

    Definition Classes
    PluginsFunctions
  13. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  15. def extraProjects: Seq[Project]

    The Projects to add to the current build.

  16. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  18. def globalSettings: Seq[Def.Setting[_]]

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

  19. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  20. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  21. val label: String

  22. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  23. 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
  24. final def notify(): Unit

    Definition Classes
    AnyRef
  25. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  26. def projectConfigurations: Seq[Configuration]

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

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

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

  28. 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.

  29. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  30. def toString(): String

    Definition Classes
    AutoPlugin → AnyRef → Any
  31. 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.

  32. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from PluginsFunctions

Inherited from Basic

Inherited from Plugins

Inherited from AnyRef

Inherited from Any

Ungrouped