0
votes

I'm trying to define a multi-project build with a consequent number of subprojects:

.
├── build.sbt
├── project/
│   ├── dependencies.scala
│   ├── tasks.scala
│   └── settings.scala
├── lib_1/
│   └── src/
├── ...
└── lib_n/
    └── src/

Those subprojects are currently defined in build.sbt:

val outputJarFolder = "/some/path/"
lazy val comonSettings = /* ... */

lazy val lib_1 = (project in file ("lib1")).settings(
    name:="LibOne",
    commonSettings,
    libraryDependencies ++= Seq(scalaTest, jsonLib, scalaXML, commonsIo),
    Compile/packageBin/artifactPath := file(outputJarFolder + "lib1.jar")
)

// ... more libs ...

lazy val lib_n = (project in file ("libn")).settings(
    name:="LibLast",
    commonSettings,
    Compile/packageBin/artifactPath := file(outputJarFolder + "libn.jar")
)
    .depensOn(lib_2, lib_12)

How can I define those subprojects in another file than build.sbt in order to "unclog" that file? I want to still be able to define them in their lexicographic order (so lazy is a must). I'm working with sbt version 1.2.8 and scala 2.10.


I've tried:

  1. Putting the declaration of those lib_k variables in a scala file and importing it --> sbt says: "classes cannot be lazy".
  2. Putting those declaration in an object (or in a class and instantiate it in build.sbt) --> sbt projects doesn't list any subproject.
1

1 Answers

1
votes

sbt documentation mentions it, but doesn't emphasize too much (perhaps to avoid encouragement for too much variation in how builds are defined in the absence of a common convention):

The build definition is described in build.sbt (actually any files named *.sbt) in the project’s base directory.

So you can split your build.sbt file into several separate .sbt files in the root of the project with different names.

I also recommend reading documentation on Organizing the build.