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:
- Determine if the
AutoPlugin
should automatically be activated when all requirements are met, or should be opt-in. - Determine the
AutoPlugin
s that, when present (or absent), act as the requirements for theAutoPlugin
. - Determine the settings/configurations to that the
AutoPlugin
injects when activated. - 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:
- Add dependencies on plugins in
project/plugins.sbt
as usual withaddSbtPlugin
- Add key plugins to projects, which will automatically select the plugin + dependent plugin settings to add for those projects.
- 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.
- Alphabetic
- By Inheritance
- AutoPlugin
- PluginsFunctions
- Basic
- Plugins
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new AutoPlugin()
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def &&(o: Basic): Plugins
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
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. -
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
derivedProjects(proj: ProjectDefinition[_]): Seq[Project]
The Projects to add to the current build based on an existing project.
-
def
empty: Plugins
Plugins instance that doesn't require any Pluginss.
- Definition Classes
- PluginsFunctions
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
extraProjects: Seq[Project]
The Projects to add to the current build.
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
globalSettings: Seq[Def.Setting[_]]
The
Setting
s to add to the global scope exactly once if any project activates this AutoPlugin. -
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val label: String
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
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
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
projectConfigurations: Seq[Configuration]
The
Configuration
s to add to each project that activates this AutoPlugin. -
def
projectSettings: Seq[Def.Setting[_]]
The
Setting
s to add in the scope of each project that activates this AutoPlugin. -
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.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AutoPlugin → AnyRef → Any
-
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
, andrequires
method returnsWeb && Javascript
, this plugin instance will be added automatically if theWeb
andJavascript
plugins are enabled.When this method returns
noTrigger
, andrequires
method returnsWeb && Javascript
, this plugin instance will be added only if the build user enables it, but it will automatically add bothWeb
andJavascript
. -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()