I am new to SBT and trying to set up a multi-module project. I come across to a situation where I would like to have a single place where I could have defined versions for libs used accross modules. I tried following with creating a custom settingKey - in the root project:
val akkaVersion = SettingKey[String]("Akka version used in our project") name := "hello-app" version in ThisBuild := "1.0.0" organization in ThisBuild := "com.jaksky.hello" scalaVersion := "2.10.4" akkaVersion in ThisBuild:= "2.3.4" // Common settings/definitions for the build def OurProject(name: String): Project = ( Project(name, file(name)) ) lazy val common = ( OurProject("common") ) lazy val be_services = ( OurProject("be-services") dependsOn(common) ) In project be-services I tried following:
libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % akkaVersion.value, "com.typesafe.akka" %% "akka-cluster" % akkaVersion.value, "com.typesafe.akka" %% "akka-kernel" % akkaVersion.value, "com.typesafe.akka" %% "akka-remote" % akkaVersion.value, "com.typesafe.akka" %% "akka-slf4j" % akkaVersion.value, "ch.qos.logback" % "logback-classic" % "1.0.13" ) The point here is akkaVersion is not visible (akkaVersion is not found - that is the error message).
My questins:
- Is settings map shared accross modules? Described issue probably answers -> NO
- What is best practice in this situation?
I found following possibilities:
- Scala object holding string constants. Seems to me a bit akward as project version is specified in build.sbt so why dependant libs should be hidden somewhere in project/GlobalVersions.scala or so.
- Crating a libDepenDency seq which can be reused. That limits flexibility and I do not always want to be dependant on those libs mentioned.
- Custom setting seems to be a bit heavy weighed but seems to me as a claean way but wasn't able to make it work.
Just to complete the picture - using SBT 0.13.5
I believe that this is so fundamental problem that I am not the first one facing this issue.
Thanks for helping me out