Ryan Wilson
Ryan Wilson

Reputation: 1793

How do you get values for settings from a build.sbt file

I'm trying to figure out how I can get the values for the settings from my build.sbt file. My sbt file looks like so...

name := "projectName"

organization := "com.organization"

version := "0.1.1"

scalaVersion := "2.11.7"

...

and so on. I need to able to get the value for name and version to use in other files in my application and I don't want to have to hardcode it. Is there a way to do this?

Upvotes: 4

Views: 2199

Answers (1)

ayvango
ayvango

Reputation: 5977

Just use .value method for properties and macros magic would do the work. See for example:

version := scalaVersion.value

update: the information above was written under presumption that project means project/* files that describe the project.


If there is need to pass some information from build to the sources then the buildinfo sbt plugin may be used. See the project page for usage description.

Upvotes: 4

Related Questions