Skip to content

Instantly share code, notes, and snippets.

@hisui
Created November 24, 2017 11:20
Show Gist options
  • Save hisui/bb7e1964ab0d9ed50cf3ae7a190966de to your computer and use it in GitHub Desktop.
Save hisui/bb7e1964ab0d9ed50cf3ae7a190966de to your computer and use it in GitHub Desktop.
lazy val generateBuildConfig = taskKey[Seq[File]]("Generates `build.conf`.")
generateBuildConfig := {
val dest = (resourceManaged in Compile).value / "build.conf"
val hash = Process("git rev-parse HEAD").!!.trim()
val time = java.time.Instant.now()
streams.value.log.info(s"Generating a build.conf: $dest")
IO.write(dest,
s"""build.info {
| hash: "$hash"
| time: "$time"
|}
""".stripMargin)
Seq(dest)
}
resourceGenerators in Compile += generateBuildConfig.taskValue
resourceGenerators in Runtime += generateBuildConfig.taskValue
resourceGenerators in (Runtime, dist) += generateBuildConfig.taskValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment