3

The following build.sbt file works, but it defines the dependencies of all subprojects:

name := "myproject"

version := "1.0"

scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
  "org.scalafx" %% "scalafx" % "8.0.60-R9"
)


lazy val aLib = (project in file("lib/a"))
lazy val bLib = (project in file("lib/b"))
  .dependsOn(aLib)
  .dependsOn(cLib)
lazy val cLib = (project in file("lib/c"))
  .dependsOn(aLib)
lazy val myApp = (project in file("myapp"))
  .dependsOn(aLib)
  .dependsOn(bLib)
  .dependsOn(cLib)
  .aggregate(aLib, bLib, cLib)

Since each subproject (directories lib/a, lib/b, lib/c, myapp) has its own build.sbt file, I would like to use those build files to define the individual dependencies of each project.

I tried to move the dependsOn/aggregate statements to the subprojects' build files, but I am not able to make it work that way. What is the recommended way?

ideaboxer
  • 3,863
  • 8
  • 43
  • 62
  • the recommended way is to not have build.sbt files in subdirectories. – Dale Wijnand May 18 '16 at 23:33
  • 1
    @DaleWijnand could you please provide a reference to sbt documentation or something else supporting your statement? – Haspemulator May 19 '16 at 07:55
  • I'm not sure if it's explicit in http://www.scala-sbt.org/0.13/docs/Basic-Def.html but I can tell you it's the recommended case from hearing the bugs, edge cases and unsupported cases in multi, nested build.sbt files. – Dale Wijnand May 19 '16 at 07:59
  • @DaleWijnand: "The recommended way is to not have build.sbt files in subdirectories". If I remove one of the subprojects' build.sbt files, the super project does not compile any more (because the subproject's Scala version is not defined). Hence this cannot be the recommended way... – ideaboxer May 23 '16 at 19:45
  • 1
    Well the transition requires more than just removing files - you would have to migrate the contents (and thus the definition of the build) of those subprojects into the root build.sbt. – Dale Wijnand May 23 '16 at 19:47

0 Answers0