Search code examples
scalaplayframeworksbtplayframework-2.3

Play 2.3.x - app name from "application.conf" in "build.sbt"


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?


Solution

  • 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")