This is how you can get Play application version and application name defined in your build.sbt
name := "myApp"
version :="1.0.4"
Notice this only works in PROD mode. In dev mode SBT shares a JVM instance with the application and those calls return something different.
Application.class.getPackage().getImplementationTitle()); // returns "myApp"
Application.class.getPackage().getImplementationVersion()); // returns "1.0.4"
In this case Application class is a class defined in your project. It can be any class from your project.
UPDATE
I noticed that this method doesn't work out of the box for Play >=2.4.x
To fix the problem add this to your build.sbt
packageOptions += Package.ManifestAttributes(
"Implementation-Version" -> (version in ThisBuild).value,
"Implementation-Title" -> name.value
)
The two properties will be appended to MANIFEST.FM file in your build so the package title and version can be read from the code.
fyi: I use SBT native packager
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3")