I'm working with a huge project with lots of subprojects, some of them with subprojects of their own. On top of that, I'd like some of them to be dynamic - given a List
somewhere in the project build, I'd like to create one project for each of the elements.
For those reasons, having to define a lazy val
for each project in build.sbt
is very cumbersome. Is there other way to declare projects, like a addProject
-like method we could call anywhere? Is there some SBT plugin that helps with that?
Sbt uses macros to turns top level val
s into projects, so I don't think you will be able to escape that part. However, you can define all you build in Project => Project
functions: (note that you also composability "for free" with function composition)
def myConf: Project => Project =
_.enablePlugins(ScalaJSPlugin)
.settings(scalaVersion := "2.12.0")
Then simply use project.configure(myConf)
for single line project definitions:
lazy val subProject1 = project.configure(myConf)
lazy val subProject2 = project.configure(myConf)
lazy val subProject3 = project.configure(myConf)
lazy val subProject4 = project.configure(myConf)
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With