I use the Play Framework 2.0 (2.0.3).
I have a Java project and want to read the application version (appVersion) defined in Build.scala.
What I already saw is that it’s possible to read certain configuration details from the Application object provided to Global.java, but didn’t find a key called appVersion or similar.
You can define the version in
application.confand letBuild.scalaread the value. I did this with the version number and application name. The following works in Play 2.0, there is an updated solution for Play 2.1.In
project/Build.scala, load the configuration and get the properties:In
conf/application.confdefine the properties:Finally in your application it will be accessible with
The configuration syntax has quite some features, so you can even go a little more crazy with your version or application names: