DRY: Defining vals that I can reuse

36 views
Skip to first unread message

Joe Barnes

unread,
Dec 1, 2012, 12:53:53 PM12/1/12
to simple-b...@googlegroups.com
Hey guys, I'd like to know the best way to define a val that I can reuse in other settings.  To be specific, I have about a dozen dependencies which have the same version.  So rather than paste the version all through my build.sbt file, I want to define it as a val or whatever and reuse it.  

Thanks,
Joe

Jason Zaugg

unread,
Dec 1, 2012, 3:09:03 PM12/1/12
to simple-b...@googlegroups.com
On Saturday, December 1, 2012 6:53:53 PM UTC+1, Joe Barnes wrote:
Hey guys, I'd like to know the best way to define a val that I can reuse in other settings.  To be specific, I have about a dozen dependencies which have the same version.  So rather than paste the version all through my build.sbt file, I want to define it as a val or whatever and reuse it.  

Right now, the .sbt format doesn't allow val definitions to share between blank-line-delimited settings. But a single setting can be a block that internally defines a val:

libraryDependencies ++= {
  val version = "1.2"
  Seq(
    "com.acme" % "a" % version,
    "com.acme" % "b" % version
}

Joe Barnes

unread,
Dec 5, 2012, 1:34:34 PM12/5/12
to simple-b...@googlegroups.com
That looks perfect.  I should have thought about that.  Thanks!

Joe
Reply all
Reply to author
Forward
0 new messages