简体   繁体   中英

How get application version in play framework and build.sbt

I'm using play 2.2 with Scala, how can I get version from build.sbt?

name := "project_name"
version := "0.2-SNAPSHOT"

play.Project.playScalaSettings

or how can I pass there value from another object?

I've added this to my build.sbt:

import com.typesafe.config._

val conf = ConfigFactory.parseFile(new File("conf/application.conf")).resolve()

version := conf.getString("app.version")

and in my application.conf:

app.version="0.2-SNAPSHOT"

Take a look at the solution using the application.conf to keep version info (you must to modify it to fit 2.2 build file): Play Framework 2: Read the application version defined in Build.scala

When you have it in application.conf you can read it easily in your controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM