I am trying to register Projects dynamically in sbt like this:
lazy val dirs = new File("path").listFiles().filter(_.isDirectory)
val subprojects = dirs.map { p =>
Project(p.getName, p).settings(name := p.getName)
}
lazy val root = (project in file("."))
.settings(
name := "gen",
libraryDependencies ++= dependencies
)
val root2 = subprojects.foldLeft(root)((x, y) => x.aggregate(y))
But when executing, I am getting:
No project 'a-sub-project' in 'file:/path'.
Seems like projects are not being registered when creating them as Project on this line:
val subprojects = dirs.map { p =>
Project(p.getName, p).settings(name := p.getName)
}
I also tried like this:
lazy val root = (project in file("."))
.aggregate(subprojects:_*)
.settings(
name := "gen",
libraryDependencies ++= dependencies
)
I get:
no `: _*' annotation allowed here (such annotations are only allowed in arguments to -parameters) .aggregate(subprojects:_)
If I run projects on sbt none of the sub projects are listed.