Reputation: 52
Using Play 2.1.x i was able to get the app name and version from the "conf/application.conf" in "project/build.scala" like this:
import sbt._
import Keys._
import play.Project._
import com.typesafe.config._
object ApplicationBuild extends Build {
val conf = ConfigFactory.parseFile(new File("conf/application.conf")).resolve()
val appName = conf.getString("application.name")
val appVersion = conf.getString("application.version")
....
I am migrating to Play 2.3.8 and I am trying to find a similar solution to get the name and version in "built.sbt". I checked the migration guides and similar questions but none seems to work.
How do i do that?
Upvotes: 1
Views: 800
Reputation: 146
My project in Play 2.3.8 works well as below.
import PlayKeys._
import com.typesafe.config._
val conf = ConfigFactory.parseFile(new File("conf/application.conf")).resolve()
name := conf.getString("application.name")
version := conf.getString("application.version")
Upvotes: 2
Reputation: 9320
I've create a couple of tests on my Play project (with version 2.3.8) and it looks like you have problem with locating this file.
When I try to read file application.conf (just for the purpose of testing) - it gives me FileNotFoundException, but suddenly Config silently ignore this problem. Anyway in my case everything works well (conf/application.conf) - and I was able retrieve any keys I want to.
So, I recommend to check if you could locate file properly - for example as first try you could replace path with absolute one, to check that parsing is working and then try to fix location problem.
Upvotes: 0