Merge pull request #4736 from eatkins/watch-alias

Allow aliases to be used in continuous builds
This commit is contained in:
Ethan Atkins 2019-05-28 22:08:51 -07:00 committed by GitHub
commit 326ea6ffbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 5 deletions

View File

@ -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(

View File

@ -0,0 +1,6 @@
val foo = taskKey[Unit]("foo")
foo := println("foo")
foo / watchOnIteration := { _ => sbt.nio.Watch.CancelWatch }
addCommandAlias("bar", "foo")
addCommandAlias("baz", "foo")

View File

@ -0,0 +1,3 @@
> ~bar
> ~baz