I’m trying to separate various settings from the build definition in my Play! 2.1 application.
I defined some settings in build.sbt as follows:
name := "My Project"
version := 1.0
How can I reuse these values in Build.scala?
object ApplicationBuild extends Build {
val main =
// Doesn't compile since name and version are SettingKeys, not Strings
play.Project(name, version).settings(
// ...
)
}
Thanks a lot!
You can use
<<=instead of:=if you need to access keys (like<+=instead of+=). In this case we want to pull the version and name from the global scope.Although since this is the default scope we can omit the scope in this case.
An even shorter version of this is simply
Note your
build.sbtfile must go in the root directorying and not theproject/directory.