Add getSetting to UpperStateOps

This returns Option[A].
This commit is contained in:
Eugene Yokota 2020-02-16 22:32:06 -05:00
parent a7d76d357c
commit 75365e13d1
1 changed files with 18 additions and 0 deletions

View File

@ -33,6 +33,20 @@ trait UpperStateOps extends Any {
private[sbt] def currentUnit: LoadedBuildUnit
/**
* Gets the value assigned to `key` in the computed settings map.
* If the project axis is not explicitly specified, it is resolved to be the current project according to the extracted `session`.
* Other axes are resolved to be `Zero` if they are not specified.
*/
def getSetting[A](key: SettingKey[A]): Option[A]
/**
* Gets the value assigned to `key` in the computed settings map.
* If the project axis is not explicitly specified, it is resolved to be the current project according to the extracted `session`.
* Other axes are resolved to be `Zero` if they are not specified.
*/
def getTaskValue[A](key: TaskKey[A]): Option[Task[A]]
/**
* Gets the value assigned to `key` in the computed settings map.
* If the project axis is not explicitly specified, it is resolved to be the current project according to the extracted `session`.
@ -111,6 +125,10 @@ object UpperStateOps {
private[sbt] def session: SessionSettings = Project.session(s)
def getSetting[A](key: SettingKey[A]): Option[A] = extract.getOpt(key)
def getTaskValue[A](key: TaskKey[A]): Option[Task[A]] = extract.getOpt(key)
def setting[A](key: SettingKey[A]): A = extract.get(key)
def taskValue[A](key: TaskKey[A]): Task[A] = extract.get(key)