Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created July 27, 2021 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuwei-k/881590291d17606a14501e72909b0943 to your computer and use it in GitHub Desktop.
Save xuwei-k/881590291d17606a14501e72909b0943 to your computer and use it in GitHub Desktop.
sbt taskAll command
commands += Command.args("taskAll", """<task name> <project id regex>""") { (s, args) =>
val taskName = args.head
val projectRegexList = args.tail
val extracted = Project.extract(s)
val currentBuildUri = extracted.currentRef.build
val buildStructure = extracted.structure
val buildUnitsMap = buildStructure.units
val currentBuildUnit = buildUnitsMap(currentBuildUri)
val projectsMap = currentBuildUnit.defined
val projects = projectsMap.values.map(_.id).toVector.filter(id => projectRegexList.exists(id matches _))
val result = projects.map(_ + "/" + taskName).mkString("all ", " ", "")
s.log.info(result)
result :: s
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment