Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 681
Michał Jurczuk Avatar asked Apr 29 '14 17:04

Michał Jurczuk


People also ask

How can I get sbt version?

Running the command, "sbt sbt-version" will simply output your current directory and the version number.

What is sbt in play framework?

sbt : The sbt settings that describe building your application. /conf : Configuration files for your application. /project : Further build description information. /public : Where static, public assets for your application are stored. /test : Where your application's test code will be stored.

What is a build sbt file?

sbt . That file lists all the source files your project consists of, along with other information about your project. Sbt will read the file and then it knows what to do to compile the complete project. Besides managing your project, some build tools, including sbt, can automatically manage dependencies for you.

What does the src folder contain in an sbt project?

The project folder contains sbt configurations and settings, while src contains all your source code. sbt creates the target folder after you compile your code; it includes the JVM bytecode of your application.


1 Answers

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"
like image 95
Michał Jurczuk Avatar answered Nov 11 '22 13:11

Michał Jurczuk