I'm working on a library and an app which depends on it in parallel, and I'd like to publish them separately. Since I frequently edit both, I'd like to be able to load both of them in IntelliJ such that "Go to definition" works correctly (i.e. takes me to the editable source of the other project), and rebuilding will incorporate changes made in the other module without having to rerun sbt publishLocal and refresh the other project.
I managed to get IntelliJ to do this by manually adding multiple SBT projects and editing their dependencies by hand, but my edits disappeared as soon as I added a library dependency and refreshed the SBT definitions.
How can I get IntelliJ to understand that a libraryDependency on the other project should be realised and imported as a module, rather than from the local maven repository?