The build info plugin is working fine for me, but I am wondering if I could add to the generated BuildInfo.scala
source file the version of the JDK with which it was generated.
sbt-buildinfo plugin: How can I add the java version in effect at compile time to the generated BuildInfo.scala?
398 views Asked by Igor Urisman At
2
There are 2 answers
2
On
You can add a SettingKey
, like:
lazy val jdkVersion: SettingKey[String] = SettingKey[String]("jdkVersion", "JDK Version")
lazy val root = (project in file(".")).
enablePlugins(BuildInfoPlugin)
.settings(
ThisBuild / jdkVersion := System.getProperty("java.version"),
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, jdkVersion),
buildInfoOptions += BuildInfoOption.ToJson,
buildInfoPackage := "myproject.version"
)
The following should do
The four properties you might want to capture are
"java.vm.name"
,"java.vm.version"
,"java.version"
,"java.runtime.version"
.