1

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?

argin
  • 52
  • 4

2 Answers2

2

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")
tsuyoshi
  • 136
  • 1
  • 4
  • this seems to rely on a certain version of sbt to be used. I'm getting this issue when trying it: http://stackoverflow.com/a/20003166/1808164 – EdgeCaseBerg Jul 24 '15 at 18:39
0

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.

Mysterion
  • 9,050
  • 3
  • 30
  • 52