mirror of https://github.com/sbt/sbt.git
Add -Dsbt.cli.nodelegation option to experiment with no delegation for running/showing tasks/settings from the command line.
With this set to true, the following is no longer allowed for example: > compile:update
This commit is contained in:
parent
5174f44dc3
commit
5f7a327e5e
|
|
@ -263,10 +263,10 @@ object Act
|
||||||
def keyValues[T](extracted: Extracted)(keys: Seq[ScopedKey[T]]): Values[T] = keyValues(extracted.structure)(keys)
|
def keyValues[T](extracted: Extracted)(keys: Seq[ScopedKey[T]]): Values[T] = keyValues(extracted.structure)(keys)
|
||||||
def keyValues[T](structure: BuildStructure)(keys: Seq[ScopedKey[T]]): Values[T] =
|
def keyValues[T](structure: BuildStructure)(keys: Seq[ScopedKey[T]]): Values[T] =
|
||||||
keys.flatMap { key =>
|
keys.flatMap { key =>
|
||||||
structure.data.get(key.scope, key.key) map { value =>
|
getValue(structure.data, key.scope, key.key) map { value => KeyValue(key, value) }
|
||||||
KeyValue(key, value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
private[this] def getValue[T](data: Settings[Scope], scope: Scope, key: AttributeKey[T]): Option[T] =
|
||||||
|
if(java.lang.Boolean.getBoolean("sbt.cli.nodelegation")) data.getDirect(scope, key) else data.get(scope, key)
|
||||||
|
|
||||||
def requireSession[T](s: State, p: => Parser[T]): Parser[T] =
|
def requireSession[T](s: State, p: => Parser[T]): Parser[T] =
|
||||||
if(s get sessionSettings isEmpty) failure("No project loaded") else p
|
if(s get sessionSettings isEmpty) failure("No project loaded") else p
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ sealed trait Settings[Scope]
|
||||||
def definingScope(scope: Scope, key: AttributeKey[_]): Option[Scope]
|
def definingScope(scope: Scope, key: AttributeKey[_]): Option[Scope]
|
||||||
def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T]
|
def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T]
|
||||||
def get[T](scope: Scope, key: AttributeKey[T]): Option[T]
|
def get[T](scope: Scope, key: AttributeKey[T]): Option[T]
|
||||||
|
def getDirect[T](scope: Scope, key: AttributeKey[T]): Option[T]
|
||||||
def set[T](scope: Scope, key: AttributeKey[T], value: T): Settings[Scope]
|
def set[T](scope: Scope, key: AttributeKey[T], value: T): Settings[Scope]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -23,11 +24,11 @@ private final class Settings0[Scope](val data: Map[Scope, AttributeMap], val del
|
||||||
def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T] = data.flatMap { case (scope, map) => map.keys.map(k => f(scope, k)) } toSeq;
|
def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T] = data.flatMap { case (scope, map) => map.keys.map(k => f(scope, k)) } toSeq;
|
||||||
|
|
||||||
def get[T](scope: Scope, key: AttributeKey[T]): Option[T] =
|
def get[T](scope: Scope, key: AttributeKey[T]): Option[T] =
|
||||||
delegates(scope).toStream.flatMap(sc => scopeLocal(sc, key) ).headOption
|
delegates(scope).toStream.flatMap(sc => getDirect(sc, key) ).headOption
|
||||||
def definingScope(scope: Scope, key: AttributeKey[_]): Option[Scope] =
|
def definingScope(scope: Scope, key: AttributeKey[_]): Option[Scope] =
|
||||||
delegates(scope).toStream.filter(sc => scopeLocal(sc, key).isDefined ).headOption
|
delegates(scope).toStream.filter(sc => getDirect(sc, key).isDefined ).headOption
|
||||||
|
|
||||||
private def scopeLocal[T](scope: Scope, key: AttributeKey[T]): Option[T] =
|
def getDirect[T](scope: Scope, key: AttributeKey[T]): Option[T] =
|
||||||
(data get scope).flatMap(_ get key)
|
(data get scope).flatMap(_ get key)
|
||||||
|
|
||||||
def set[T](scope: Scope, key: AttributeKey[T], value: T): Settings[Scope] =
|
def set[T](scope: Scope, key: AttributeKey[T], value: T): Settings[Scope] =
|
||||||
|
|
@ -74,7 +75,7 @@ trait Init[Scope]
|
||||||
new Apply[({ type l[L[x]] = List[L[S]] })#l, T](f, inputs.toList, AList.seq[S])
|
new Apply[({ type l[L[x]] = List[L[S]] })#l, T](f, inputs.toList, AList.seq[S])
|
||||||
|
|
||||||
/** Constructs a derived setting that will be automatically defined in every scope where one of its dependencies
|
/** Constructs a derived setting that will be automatically defined in every scope where one of its dependencies
|
||||||
* is explicitly defined and the where the scope matches `filter`.
|
* is explicitly defined and the where the scope matches `filter`.
|
||||||
* A setting initialized with dynamic dependencies is only allowed if `allowDynamic` is true.
|
* A setting initialized with dynamic dependencies is only allowed if `allowDynamic` is true.
|
||||||
* Only the static dependencies are tracked, however. */
|
* Only the static dependencies are tracked, however. */
|
||||||
final def derive[T](s: Setting[T], allowDynamic: Boolean = false, filter: Scope => Boolean = const(true), trigger: AttributeKey[_] => Boolean = const(true)): Setting[T] = {
|
final def derive[T](s: Setting[T], allowDynamic: Boolean = false, filter: Scope => Boolean = const(true), trigger: AttributeKey[_] => Boolean = const(true)): Setting[T] = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue