Sometimes a build combines multiple source directories, each of which is their own 'project'. For instance, you might have a build structure like this:
projectName/ build.sbt project/ src/ main/ ... test/ ... core/ src/ main/ ... test/ ... webapp/ src/ main/ ... test/ ...
In the above project, the code in
projectName/src is considered the
root project. There are two other modules, or 'subprojects',
Configuring a subproject is similar to configuring the root project, except that the subdirectory is specified in the project. This example shows a root project that aggregates a
lazy val root = (project in file(".")).aggregate(core,webapp).dependsOn(core, webapp) lazy val core = (project in file("core")) lazy val webapp = (project in file("webapp")).dependsOn(core)
The values passed to
file() are the directories relative to the project root.
webapp project depends on the
core project, which is indicated by the
dependsOn clause, which takes the
core value specified on the line above.
lazy evaluation ensure that dependencies are available before projects utilize them. In this case,
webapp depends on
core will be compiled before the build attempts to compile
aggregate makes tasks defined in one project available to the project that aggregates it. For instance, executing
compile in the
root project will also execute