Reputation: 3517
I have many modules in the same project such that the structure is somethign along the lines of:
Root
- ProjA
- ProbB
- ProjC
build.sbt
I had a build.sbt with all of the details in at the root of the project, it was clunky and we encountered problems when I needed to give someone ProjB.
I then found a post and slides on Effective SBT and thought it sounded like a great solution. Implementation has not bee painless though.
I'm updating the structure to look like:
Root
- ProjA
--build.props
--dependencies.scala
-ProjA
--build.props
--dependencies.scala
build.sbt
example of Dependencies:
object Dependencies {
//specific versions (if required) use '% name-version' to add to the dependency
//libraries
val scalaTest = "org.scalatest" % "scalatest_2.10" % "2.2.6"
val slf4j = "org.slf4j" % "slf4j-log4j12" % "1.7.13"
val akkaActor = "com.typesafe.akka" % "akka-actor_2.10" % "2.3.14"
val akkaTest = "com.typesafe.akka" % "akka-testkit_2.10" % "2.3.14"
val awsCloudwatch = "com.amazonaws" % "aws-java-sdk-cloudwatch" %
"1.10.28"
val cloudwatchDependencies = Seq(awsCloudwatch, akkaActor, akkaTest)
I'm then trying to use this in my build.sbt but it won't allow me to import the file
in build.sbt I have:
lazy val cloudwatch = (project in file("cloudwatch")).
settings(commonSettings: _*).
settings(
name := "Cloudwatch",
libraryDependencies += cloudwatchDependencies
)
but I'm unable to import or pick up the dependencies. Is there something obviously wrong that I'm missing? Is it the correct/wrong approach?
Thanks for any help / advice
Upvotes: 1
Views: 175
Reputation: 10904
The configuration objects need to reside at a special place: /project
.
If you move them there everything should be fine.
see: http://www.scala-sbt.org/0.13.5/docs/Getting-Started/Multi-Project.html#common-code
If you want to have a per project configuration, it is possible to have a separate build.sbt
for each project. This approach bears the additional gain that it is the idiomatic way to approach this problem.
The setup could look like this:
root
-build.sbt
-cloudwatch.sbt
- ProjA
--build.sbt
-ProjB
--build.sbt
If you still need more granularity, it would be possible to have several *.sbt
files, which will all be included in the build.sbt
root
-build.sbt
- ProjA
--build.sbt
-ProjB
--build.sbt
Upvotes: 1