mirror of https://github.com/sbt/sbt.git
[2.x] Disable delegation on shell (#8539)
**Problem** Currently the shell delegates request tasks even when a non-existent task like Compile / update is requested. **Solution** This removes the delegation, if the input key is scoped, so it will fail. We will, however, continue to delegate on the subproject axis, since it's useful to use Global or ThisBuild scoping.
This commit is contained in:
parent
c832fad7b5
commit
8b4b89c395
|
|
@ -573,8 +573,14 @@ object Act {
|
|||
private def anyKeyValues(structure: BuildStructure, keys: Seq[ScopedKey[?]]): Seq[KeyValue[?]] =
|
||||
keys.flatMap(key => getValue(structure.data, key).map(KeyValue(key, _)))
|
||||
|
||||
/**
|
||||
* Starting sbt 2.0.0, we will not delegate when a non-existent scoping
|
||||
* such as Compile / update is required.
|
||||
*/
|
||||
private def getValue[T](data: Def.Settings, key: ScopedKey[T]): Option[T] =
|
||||
if (java.lang.Boolean.getBoolean("sbt.cli.nodelegation")) data.getDirect(key)
|
||||
if key.scope.config.isSelect ||
|
||||
key.scope.task.isSelect
|
||||
then data.getDirect(key)
|
||||
else data.get(key)
|
||||
|
||||
def requireSession[T](s: State, p: => Parser[T]): Parser[T] =
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
scalaVersion := "3.7.4"
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
> compile
|
||||
> test
|
||||
|
||||
# Fail on non-existent scoping
|
||||
-> Compile / update
|
||||
|
||||
Loading…
Reference in New Issue