Merge pull request #5440 from eed3si9n/wip/getsetting

Add getSetting to UpperStateOps
This commit is contained in:
eugene yokota 2020-02-18 13:52:29 -05:00 committed by GitHub
commit 523795e204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)