Create Scala multiproject with IntelliJ?

Hello everyone,

I’d like to create a multi-project build with IntelliJ.

I found those information:
https://alvinalexander.com/scala/how-to-create-sbt-projects-with-subprojects/

It says that we need to “Create your subproject as a regular SBT project, but without a project subdirectory.” How to do that ( I mean without the project directory) with IntelliJ ? Each time I create a project with IntelliJ, a project subdirectory is always created.

I found several examples but they all explain how to create those subprojects manually, on command line, e.g.:
https://manuel.kiessling.net/2015/01/19/setting-up-a-scala-sbt-multi-project-with-cassandra-connectivity-and-migrations/.

Also as I am new to Scala, I’d like to know if it is common to use such multi-project build in Scala ? What is the difference between a multi-project builds and a single build/project with packages (I found the latter easier to create/debug) ?

Finally, how would you do to debug/develop such a multi-project build ?

Thank you very much,
Best regards

The main necessity for multiple modules is for different build targets, for instance JVM-only, JS-only, and code shared between them; to publish a library as multiple artifacts so users don’t get too much on their classpath they don’t need; and to create enforced modularity boundaries. With packages there’s nothing stopping code everywhere from depending on code everywhere else; they are simply a namespacing device. Build modules lets you isolate and constrain what parts of the code can depend on what parts.

Thank you

It is still unclear for me if I can run each subproject independently, i.e. with their own build.sbt file.

In https://alvinalexander.com/scala/how-to-create-sbt-projects-with-subprojects/

It says: " Create your subproject as a regular SBT project, but without a project subdirectory" with a sbt file for each subproject.

Suppose for example that I have an independent project (A) on its own (with its main function, its build.sbt), and I want to use/add it as a subproject to another project (B): how can do that without modifying A ?

Thank you,
Best regards

Supporting multi-module projects
https://github.com/xerial/sbt-pack