How to manage multiple interdependent modules with SBT and IntelliJ IDEA?

The approach with multi-project build is the correct one. You can have a nested tree of subprojects of arbitrary length, but you cannot have a module belonging to multiple parent projects. This makes absolutely sense, and in Maven happens the same.

The reason is that it would be hard to have the same module into multiple projects and keep the sources synchronized. A normal workflow is the following:

  • You have a project which the module belongs to, where you modify the module source.
  • You publish the module into your local repository
  • In other projects where you need the module, you declare it as a libraryDependency

If you want to load a module which does not belong to the current project inside Idea, this is however feasible as you can add this as an external module to the workspace:

  • SBT-IDEA generates the .iml files for your project and you import them in the workspace
  • You can add other.iml of other projects to the workspace
  • If you modify external SBT modules that you have manually added to the workspace, you should republish them to get the changes visibile on the “main” project, which sees those external modules are a “libraryDependency”

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)