scala - Idiomatic way to write multi-project builds with .sbt files in sbt 0.13 -
i hear .sbt files have been improved in various ways in 0.13, , can specify multi-project builds in them.
http://www.scala-sbt.org/0.13.0/docs/community/changesummary_0.13.0.html#sbt-format-enhancements mentions can define subprojects in .sbt file. know multiple .sbt files in root aggregated single conceptual file.
what i'd like, though, not pollute root dozen subproject .sbt files. there way can throw subproject build.sbt files respective subdirectories, keep common code between them somewhere shared, , have root build.sbt entire project aggregates subprojects? have similar setup in .scala files right prefer use .sbt files if possible.
if isn't possible, "correct" way construct large multi-project builds .sbt files?
it should case in 0.12 can put .sbt
files in base directory of subproject , settings there included in project's scope.
code reused between .sbt
files creating normal .scala
file in project/
. code in project/
available use in .sbt
files. definitions in 1 .sbt
not visible other .sbt
files, @ least in 0.13. implementation restriction , undetermined whether lifted in future versions.
the default root project aggregate subprojects, including coming projects defined in subproject/build.sbt
.
the current difficulty making explicit. example, following build.sbt
in root directory define subproject in sub/
. full definition, defining id, base directory, etc... project.
<root>/build.sbt
lazy val sub = project
however, cannot reference defined in <sub>/build.sbt
. (the existence of sub/build.sbt
not known until after <root>/build.sbt
compiled , evaluated.) so, explicitly define sub
aggregates, you'd need like:
sub/build.sbt
lazy val sub = project.in(file(".")).aggregates(subsub) //or: lazy val sub = project in file(".") aggregate subsub lazy val subsub = project
however, duplicates definition of sub
.
a possible solution going forward make root definition reference, like:
<root>/build.sbt
lazy val sub = localproject("sub")
Comments
Post a Comment