Is it possible to create a hierarchical multi-project assembly using sbt?
I know this has been asked before, but all of these questions have either been removed or have not received satisfactory answers, so again I ask:
In an SBT assembly, can you organize and define subprojects in a hierarchical way? eg:.
root
foo
foofoo
foobar
bar
barfoo
barbar
where each project has its own build.sbt
, but inherits settings from its top-level project (aggregator) (therefore, foofoo
both foobar
inherit settings from foo
and foo
inherit settings from root
)
Maven has such a capability, but cross-building is very painful with this, so I want to use SBT.
If it can be done, how to do it?
source to share
This can be done by customizing your build.sbtroot project
. build.sbt in your case will look something like this:
lazy val root = (project in file(".")).enablePlugins(PlayScala) //assuming its a play scala project
lazy val foo = project.in(file("<path-to-foo-project>")).dependsOn(root)
lazy val bar = project.in(file("<path-to-bar-project>")).dependsOn(root)
lazy val foofoo = project.in(file("<path-to-foofoo-project>")).dependsOn(foo)
lazy val foobar = project.in(file("<path-to-foobar-project>")).dependsOn(foo)
lazy val barfoo = project.in(file("<path-to-barfoo-project>")).dependsOn(bar)
lazy val barbar = project.in(file("<path-to-barbar-project>")).dependsOn(bar)
source to share
refer to this: https://www.scala-sbt.org/0.13/docs/Multi-Project.html#Default+root+project
you can define multiple sbt files in subdirectories and use root sbt to include them. they will automatically be merged into one large database to run.
Any .sbt files in foo, such as foo / build.sbt, will be merged with the build definition for the entire build, but included in the hello-foo project.
source to share