В итоге мы использовали комбинацию плагинов sbt-buildinfo и Vcs через sbt-release для выполнения этой работы. Вот что мы поместили в наш файл build.sbt:
lazy val root = (project in file(".")).
enablePlugins(BuildInfoPlugin).
settings(
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion,
// actions are computed at compile time
BuildInfoKey.action("buildTime") {
LocalDateTime.now(Clock.systemUTC())
},
// actions are computed at compile time
BuildInfoKey.action("buildUser") {
val user = System.getenv("USER")
val username = System.getenv("USERNAME")
if (user != null) user
else if (username != null) username
else "Unknown"
},
BuildInfoKey.action("buildSha") {
// Find the current version control system and get the current hash of it
Vcs.detect(new File(".")).map(_.currentHash)
}
),
buildInfoPackage := "company.package"
)
Ключевым битом здесь является то, что действия BuildInfo рассчитываются и устанавливаются во время компиляции, а не во время выполнения.