From user settings and tasks :
Keys are one of three types: SettingKey, TaskKey, and InputKey.
An example of a key might be:
val scalaVersion = settingKey[String]("The version of Scala used for building.")
It is available by default in sbt and asks for the value you are executing show:
> show scalaVersion
[info] 2.10.4
Run inspectto find out about the details of the key (this is not entirely about the key, but about tuning, as you will soon know):
> inspect scalaVersion
[info] Setting: java.lang.String = 2.10.4
[info] Description:
[info] The version of Scala used for building.
[info] Provided by:
[info] **:scalaVersion
[info] Related:
[info] *
You can define your own key using a macro SettingKey:
lazy val abc: sbt.SettingKey[String] = settingKey[String]("My own setting key")
According to scaladoc sbt.SettingKey :
. : , , . Scope. AttributeKey [T]. .
scaladoc, SettingKey def scope: Scope, . .
, ( ). Initialize[T] T SettingKey[T] :=, += ++= ( ) <++=, <+= <<= ( Scala , scaladoc sbt.SettingKey).
abc := "my value"
( ):
abc.:=("my value")
:=:
final def :=(v: T): Def.Setting[T]
Setting[T].
, (SettingKey[T], Initialize[T]) (SettingKey[T], T) Setting[T].
Setting[T], T - , , . , .
, , .
, . final def in(scope: Scope): SettingKey[T].
inspect, .
> inspect abc
[info] Setting: java.lang.String = my value
[info] Description:
[info] My new setting key
[info] Provided by:
[info] {file:/Users/jacek/sandbox/sbt-theory/}sbt-theory*:abc
, ( Delegates) *:abc, {.}/*:abc */*:abc. , A/B:K, A - , B - K ( sbt attibutes, ::).
, *:abc. inspect it.
> inspect *:abc
[info] Setting: java.lang.String = my value
[info] Description:
[info] My new setting key
[info] Provided by:
[info] {file:/Users/jacek/sandbox/sbt-theory/}sbt-theory*:abc
, {.}/*:abc , {.} *. inspect it.
> inspect {.}*:abc
[info] Related:
[info] *:abc
abc ThisBuild (aka ThisBuild). build.sbt, :
abc in ThisBuild := "abc in ThisBuild"
inspect ( reload, ):
> inspect {.}*:abc
[info] Related:
[info] *:abc
build.sbt :
lazy val abc: sbt.SettingKey[String] = settingKey[String]("My new setting key")
abc := "my value"
abc in ThisBuild := "abc in ThisBuild"
, abc, - ThisBuild Global. ? !