How to automatically aggregate all subprojects in a large SBT project without having to write a large “aggregate”?

In my SBT project, I have a root project that explicitly aggregates everything, for example:

lazy val root = project.in(file(".")).
  settings(
    name := "awesome_project",
    publishArtifact := false
  ).
  aggregate(
    some_project,
    some_other_project,
    a_cool_library,
    // lots and lots and lots more
  )

Since I explicitly have to add each project to aggregatewhenever a new one is added, is there a way to do this automatically? I am currently using a shell script to do this, which searches for all lines containing lazy valand project, displays a semicolon list for each name, and I copy this list to aggregate, but I'm drawing should be an easier way to do this.

+4
source share
1 answer

, , :

protected val prjs = this.getClass.getDeclaredFields.flatMap { f =>
    f.setAccessible(true)
    f.get(this) match {
      case p@Project => Some(f.asInstanceOf[Project])
      case _ => None
    }
  }.map(x => Project.projectToRef(x))
0

Source: https://habr.com/ru/post/1618080/


All Articles