I am trying to create a script to make the release of my Play application and I would like to be able to read the version set in the 'application.conf' file.
app.version = "0.1.1"
Is there any command in SBT to read values from the Typesafe config? Or, do I need to parse the file myself?
I don't need to read the value inside the application. What I need is to get the version from the command line so that I can use it for filenames or automatic git commits.
Solution (or hack):
I have created a task in the build.sbt file:
val getAppVersion = taskKeyString
lazy val root = (project in file("."))
.settings(
Seq(organization := "com.example", version := "0.1.0-SNAPSHOT"),
showSuccess := false,
getAppVersion := {
println(version.value)
version.value
}
)
And then I can run it and read the value:
OUTPUT="$(sbt -batch --error getAppVersion)"
echo $OUTPUT
I used the -batch
and --error
flags to remove the logs and showSuccess := false
settings to remove the result log