Search code examples
scalasbtprojects

Can we define nested projects in a SBT project?


We can define multi projects in a SBT project, like:

lazy val core = project in file("core")
lazy val web = project in file("web")
lazy val shared = project in file("shared")

But is it possible to define nested projects inside a sub project? Like:

lazy val nested = project in file("nested")
lazy val nested1 = project in file("nested/nested1")
lazy val nested2 = project in file("nested/nested2")

When I run projects, it will show all defined projects in flat list:

> projects
[info] In file:/Users/twer/workspace/sbt-dependency-export-plugin-test/
[info]     core
[info]     nested
[info]     nested1
[info]     nested2
[info]   * root
[info]     shared
[info]     web

This is not what I expected, actually, I want it to be a tree, like:

core
nested
   \-- nested1
   \-- nested2
root
shared
web

I want the nested1 and nested2 to be the sub projects of the nested, but not the whole project.

Is it possible?


Solution

  • projects will always just show the project ids in a list.

    But, I think, to do what you want you just need to do this:

    lazy val nested = project in file("nested") aggregate (nested1, nested2)