Created
November 24, 2017 11:20
-
-
Save hisui/bb7e1964ab0d9ed50cf3ae7a190966de to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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