sbt
package sbt
- Alphabetic
- Public
- All
Type Members
-
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").
An AutoPlugin defines a group of settings and the conditions where the settings are automatically added to a build (called "activation"). The
requires
andtrigger
methods together define the conditions, and a method likeprojectSettings
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 theWeb
andJavascript
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 definesmyProject.enablePlugins(Web && Javascript).disablePlugins(MyPlugin)
then the
MyPlugin
settings (and anything that activates only whenMyPlugin
is activated) will not be added. - Determine if the
-
final
class
AutoPluginException extends RuntimeException
An error that occurs when auto-plugins aren't configured properly.
An error that occurs when auto-plugins aren't configured properly. It translates the error from the underlying logic system to be targeted at end users.
- abstract class BackgroundJobService extends Closeable
- trait BuildCommon extends AnyRef
- trait BuildExtra extends BuildCommon with DefExtra
-
sealed
trait
ClassLoaderLayeringStrategy extends AnyRef
Represents a ClassLoader layering strategy.
Represents a ClassLoader layering strategy. By providing an instance of ClassLoaderLayeringStrategy, users can configure the strategy that they want to use in various sbt tasks, most importantly Keys.run and Keys.test. This setting is only relevant if fork := false in the task for which we obtain a ClassLoaderLayeringStrategy.
ClassLoaders can be composed of multiple ClassLoaders to form a graph for loading a class. The different portions of the graph may be cached and reused to minimize both the memory taken up by ClassLoaders (and the classes that they load) and the startup time for tasks like test and run. For example, the scala library is large and takes a while just to load the classes in predef. The Keys.scalaInstance task provides access to a classloader that can load all of the java bootstrap classes and scala.*. Supposing that we want to run code in a jar containing scala code called "foo_2.12.jar" in the base directory and that we have a scala instance in scope and suppose further that "foo_2.12.jar" contains a main method in the class foo.Main, then we can invoke foo.Main.main like so
val fooJarFile = new File("foo_2.12.jar") val classLoader = new URLClassLoader( Array(fooJarFile.toURI.toURL), scalaInstance.loaderLibraryOnly) val main = classLoader.loadClass("foo.Main").getDeclaredMethod("main", classOf[Array[String]]) main.invoke(null, Array.empty[String])
Now suppose that we have an alternative jar "foo_alt_2.12.jar" that also provides foo.Main, then we can run that main method:
val fooJarFile = new File("foo_alt_2.12.jar") val altClassLoader = new URLClassLoader( Array(fooAltJarFile.toURI.toURL), scalaInstance.loaderLibraryOnly) val altMain = classLoader.loadClass("foo.Main").getDeclaredMethod("main", classOf[Array[String]]) altMain.invoke(null, Array.empty[String])
In the second invocation, the scala library will have already been loaded by the scalaInstance.loaderLibraryOnly ClassLoader. This can reduce the startup time by O(500ms) and prevents an accumulation of scala related Class objects. Note that these ClassLoaders should only be used at a code boundary such that their loaded classes do not leak outside of the defining scope. This is because the layered class loaders can create mutually incompatible classes. For example, in the example above, suppose that there is a class foo.Bar provided by both "foo_2.12.jar" and "foo_2.12.jar" and that both also provide a static method "foo.Foo$.bar" that returns an instance of foo.Bar, then the following code will not work:
Thread.currentThread.setContextClassLoader(altClassLoader) val bar: Object = classLoader.loadClass("foo.Foo$").getDeclaredMethod("bar").invoke(null) val barTyped: foo.Bar = bar.asInstanceOf[foo.Bar] // throws ClassCastException because the thread context class loader is altClassLoader, but // but bar was loaded by classLoader.
In general, this should only happen if the user explicitly overrides the thread context ClassLoader or uses reflection to manipulate classes loaded by different loaders.
- sealed trait ClasspathDep[PR <: ProjectReference] extends AnyRef
- final case class ClasspathDependency(project: ProjectReference, configuration: Option[String]) extends ClasspathDep[ProjectReference] with Product with Serializable
- trait CommandLineUIService extends InteractionService
- trait CompositeProject extends AnyRef
- final class ConsoleMain extends AppMain
- trait DefExtra extends AnyRef
-
sealed
trait
EvaluateTaskConfig extends AnyRef
The new API for running tasks.
The new API for running tasks.
This represents all the hooks possible when running the task engine. We expose this trait so that we can, in a binary compatible way, modify what is used inside this configuration and how to construct it.
- final case class Extracted(structure: BuildStructure, session: SessionSettings, currentRef: ProjectRef)(implicit showKey: Show[Def.ScopedKey[_]]) extends Product with Serializable
-
abstract
class
InteractionService extends AnyRef
InteractionService provides an abstration over standard input.
InteractionService provides an abstration over standard input. In the future this could be used to ask for inputs from other forms of sbt clients such as thin clients and IDEs.
- final class JavaVersion extends Serializable
- abstract class JobHandle extends AnyRef
- trait OptionSyntax extends AnyRef
- final case class PluginData(dependencyClasspath: Seq[Attributed[File]], definitionClasspath: Seq[Attributed[File]], resolvers: Option[Vector[Resolver]], report: Option[UpdateReport], scalacOptions: Seq[String]) extends Product with Serializable
-
sealed abstract
class
PluginTrigger extends Serializable
Type for AutoPlugin's trigger method.
Type for AutoPlugin's trigger method. Determines whether an AutoPlugin will be activated for a project when the
requires
clause is satisfied. -
sealed
trait
Plugins extends AnyRef
An expression that matches
AutoPlugin
s. - sealed trait PluginsFunctions extends AnyRef
- sealed trait Project extends ProjectDefinition[ProjectReference] with CompositeProject
- sealed trait ProjectDefinition[PR <: ProjectReference] extends AnyRef
- trait ProjectExtra extends AnyRef
-
sealed abstract
class
ProjectOrigin extends Serializable
Indicate whether the project was created organically, synthesized by a plugin, or is a "generic root" project supplied by sbt when a project doesn't exist for
file(".")
. - final case class ResolvedClasspathDependency(project: ProjectRef, configuration: Option[String]) extends ClasspathDep[ProjectRef] with Product with Serializable
- sealed trait ResolvedProject extends ProjectDefinition[ProjectRef]
-
class
RichURI extends AnyRef
Extends
URI
with additional convenience methods. -
trait
RunningTaskEngine extends AnyRef
An API that allows you to cancel executing tasks upon some signal.
An API that allows you to cancel executing tasks upon some signal.
For example, this is implemented by the TaskEngine; invoking
cancelAndShutdown()
allows you to cancel the current task execution. - final case class ScopedKeyData[A](scoped: Def.ScopedKey[A], value: Any) extends Product with Serializable
- final class ScriptMain extends AppMain
-
final
class
StateTransform extends AnyRef
Provides a mechanism for a task to transform the state based on the result of the task.
Provides a mechanism for a task to transform the state based on the result of the task. For example:
val foo = AttributeKey[String]("foo") val setFoo = taskKey[StateTransform]("") setFoo := { state.value.get(foo) match { case None => StateTransform(_.put(foo, "foo")) case _ => StateTransform(identity) } } val getFoo = taskKey[Option[String]] getFoo := state.value.get(foo)
Prior to a call to
setFoo
,getFoo
will returnNone
. After a call tosetFoo
,getFoo
will returnSome("foo")
. -
trait
TaskCancellationStrategy extends AnyRef
A strategy for being able to cancel tasks.
A strategy for being able to cancel tasks.
Implementations of this trait determine what will trigger
cancel()
for the task engine, providing in thestart
method.All methods on this API are expected to be called from the same thread.
-
trait
Terminal extends AnyRef
A Terminal represents a ui connection to sbt.
A Terminal represents a ui connection to sbt. It may control the embedded console for an sbt server or it may control a remote client connected through sbtn. The Terminal is particularly useful whenever an sbt task needs to receive input from the user.
-
trait
UpperStateOps extends Any
Extends State with setting-level knowledge.
-
final
class
xMain extends AppMain
This class is the entry point for sbt.
Value Members
- object AutoPluginException extends Serializable
- object BackgroundJobService
- object BuildPaths
- object BuiltinCommands
-
object
ClassLoaderLayeringStrategy
Provides instances of ClassLoaderLayeringStrategy that can be used to define the ClassLoader used by Keys.run, Keys.test or any other task that runs java code inside of the sbt jvm.
- object Classpaths
- object CommandLineUIService extends InteractionService with CommandLineUIService
-
object
Cross
Cross implements the Scala cross building commands: + ("cross") command and ++ ("switch") command.
- object DefaultOptions
- object Defaults extends BuildCommon
- object EvaluateTask
- object EvaluateTaskConfig
- object JavaVersion extends Serializable
- object Keys
- object MainLoop
- object OptionSyntax extends OptionSyntax
-
object
Opts
Options for well-known tasks.
- object PluginData extends Serializable
- object PluginTrigger extends Serializable
- object Plugins extends PluginsFunctions
- object Project extends ProjectExtra
- object ProjectOrigin extends Serializable
- object Resolvers
- object RichURI
- object ScopeFilter
- object ScriptedPlugin extends AutoPlugin
- object SessionVar
- object StandardMain
- object StateTransform
- object Tags
- object TaskCancellationStrategy
- object UpperStateOps