Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Last active June 24, 2021 01:09
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuwei-k/6278769 to your computer and use it in GitHub Desktop.
Save xuwei-k/6278769 to your computer and use it in GitHub Desktop.
show message when sbt build files changed
val buildFiles = SettingKey[Map[File, Seq[Byte]]]("build-files")
buildFiles := getBuildFiles((baseDirectory in ThisBuild).value)
def getBuildFiles(base: File) =
((base * "*.sbt") +++ ((base / "project") ** ("*.scala" | "*.sbt"))).get.map{
f => f -> collection.mutable.WrappedArray.make[Byte](Hash(f))
}.toMap
def changed(base: File, files: Map[File, Seq[Byte]]): Boolean =
getBuildFiles(base) != files
shellPrompt in ThisBuild := { state => {
if(changed((baseDirectory in ThisBuild).value, buildFiles.value))
scala.Console.RED + "build files changed. please reload project\n" + scala.Console.RESET
else ""
} + "> "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment