Last active
June 24, 2021 01:09
-
-
Save xuwei-k/6278769 to your computer and use it in GitHub Desktop.
show message when sbt build files changed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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