diff --git a/main/src/main/scala/sbt/internal/Continuous.scala b/main/src/main/scala/sbt/internal/Continuous.scala index 693142ab4..d9f9e92c4 100644 --- a/main/src/main/scala/sbt/internal/Continuous.scala +++ b/main/src/main/scala/sbt/internal/Continuous.scala @@ -380,12 +380,21 @@ private[sbt] object Continuous extends DeprecatedContinuous { // We have to add the <~ Parsers.any.* to ensure that we're able to extract the input key // from input tasks. val scopedKeyParser: Parser[Seq[ScopedKey[_]]] = Act.aggregatedKeyParser(state) <~ Parsers.any.* - Parser.parse(command, scopedKeyParser) match { - case Right(scopedKeys: Seq[ScopedKey[_]]) => scopedKeys - case Left(e) => - throw new IllegalStateException(s"Error attempting to extract scope from $command: $e.") - case _ => Nil: Seq[ScopedKey[_]] + @tailrec def impl(current: String): Seq[ScopedKey[_]] = { + Parser.parse(current, scopedKeyParser) match { + case Right(scopedKeys: Seq[ScopedKey[_]]) => scopedKeys + case Left(e) => + val aliases = BasicCommands.allAliases(state) + aliases.collectFirst { case (`command`, aliased) => aliased } match { + case Some(aliased) => impl(aliased) + case _ => + val msg = s"Error attempting to extract scope from $command: $e." + throw new IllegalStateException(msg) + } + case _ => Nil: Seq[ScopedKey[_]] + } } + impl(command) } private def getAllConfigs( diff --git a/sbt/src/sbt-test/watch/alias/build.sbt b/sbt/src/sbt-test/watch/alias/build.sbt new file mode 100644 index 000000000..0fab94fd9 --- /dev/null +++ b/sbt/src/sbt-test/watch/alias/build.sbt @@ -0,0 +1,6 @@ +val foo = taskKey[Unit]("foo") +foo := println("foo") + +foo / watchOnIteration := { _ => sbt.nio.Watch.CancelWatch } +addCommandAlias("bar", "foo") +addCommandAlias("baz", "foo") diff --git a/sbt/src/sbt-test/watch/alias/test b/sbt/src/sbt-test/watch/alias/test new file mode 100644 index 000000000..6781c97b8 --- /dev/null +++ b/sbt/src/sbt-test/watch/alias/test @@ -0,0 +1,3 @@ +> ~bar + +> ~baz \ No newline at end of file