1

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

kepa
  • 55
  • 5
  • Possible duplicate of [Play Framework 2: Read the application version defined in Build.scala](https://stackoverflow.com/questions/12369967/play-framework-2-read-the-application-version-defined-in-build-scala) – laughedelic Mar 26 '18 at 23:56
  • This [answer](https://stackoverflow.com/a/12377155/736957) should work for you. – laughedelic Mar 26 '18 at 23:57
  • Maybe my description is not correct. I don't want to read the version from inside the application. I already have that. I want to read the version from the command line so that I can use it to define the file-names and tagging the git commits automatically – kepa Mar 27 '18 at 07:51

0 Answers0