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.
Asked
Active
Viewed 385 times
1

Igor Urisman
- 717
- 1
- 6
- 22
2 Answers
4
The following should do
buildInfoKeys += BuildInfoKey.action("javaVersion")(sys.props("java.version"))
The four properties you might want to capture are "java.vm.name"
, "java.vm.version"
, "java.version"
, "java.runtime.version"
.

0__
- 66,707
- 21
- 171
- 266
2
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"
)

pme
- 14,156
- 3
- 52
- 95
-
Thank you. I didn't try this as 0__'s answer above is shorter, but suspect it would also work. I wish I could accept two answers. – Igor Urisman Dec 21 '19 at 20:59
-
1you can still upvote it;) But you are right cool answer from @0__ – pme Dec 22 '19 at 08:40