Reputation: 19
I'm writing a command in a project/MyCommand.scala file. I need to access to a val defined in my build.sbt such as:
val scala3 = "3.1.3"
I do not know how to get it from the state.
Thanks.
Upvotes: 0
Views: 126
Reputation: 1293
The common approach for that would be to define the val
s (or def
s) you need to access within the project directory, e.g. like this:
// in project/ProjectConstants.scala
object ProjectConstants {
val Scala3Version = "3.1.3"
}
Then you could access that from both your build.sbt
and from other code that resides in the project directory:
// works in both build.sbt and project/MyCommand.scala:
val scala3 = ProjectConstants.Scala3Version
Upvotes: 1