1

Current situation

I have the following directory structure for scala projects:

~/development/projects/projectA
~/development/projects/projectB
~/development/projects/projectC
...

I wrote an sbt build definition to build all the projects from a root project:

~/development/projects/build.sbt

The file is written with entries for each project:

lazy val projectA = project

lazy val projectB = project.dependsOn(projectB)
...

Every time I add a project or change the dependencies beetween the projects I have to update this file.

Target

I don't think it is necessary to do that manually. Each project already contains a build.sbt file, in which the project's dependencies is configured.

So sbt already knows about all the dependencies and the root project should be able to find all the projects easily, because these are located in subdirectories containing a build.sbt file.

Is there an existing mechanism or plugin that automatically takes all the projects, analyses their dependencies and build them all in order?

It would be perfect if it can handle recursive subproject directory structures like this:

~/development/projects/domainA/projectA
~/development/projects/domainA/projectA
~/development/projects/domainB/projectC
~/development/projects/domainB/projectD
....

If there is not such a mechanism or plugin:

  • Maybe I missunderstood something. How do other people build multiple interdependend projects?
  • Should I write a task or plugin myself to make sbt do what I want? Any hints on this?
user573215
  • 4,679
  • 5
  • 22
  • 25

1 Answers1

0

Actually, the root Project's build.sbt contains all informations about dependsOn() and aggregate().

You don't need to configure child project's build.sbt dependencies to other modules.

To run a module as independent entity, you just need to use the provided project subModule function. SBT will look at the root project dependency and rebuild local dependencies.

Juergen
  • 12,378
  • 7
  • 39
  • 55
  • you can see a poc at: https://github.com/pelodelfuego/play-2.3-multiModular-javaTemplate.git – Clément Crepy Feb 24 '15 at 00:08
  • Thx, for answering. If I understand you correctly, this is just the way I am using, it but not the way I think it should be used. As most of my projects are application independent they might be used as dependencies for multiple other applications. So they should take care of their dependencies on their own. But I need a way to build all projects in order, which would be multiple project builds. But for multiple project builds I have to specify the dependencies again. I think multiple project builds should read all project's build.sbt files and take the dependencies and build order from there. – user573215 Jul 06 '15 at 20:06
  • I agree with you, I guess a proper mechanism should exist but I couldn't find it. However this workaround avoid cyclic dependancies which are not supported by sbt. – Clément Crepy Jul 09 '15 at 01:41
  • Ps: To make it possible I guess you will need to disable lazy loading of projects. – Clément Crepy Jul 09 '15 at 01:57