title: How to manage multiple interdependent modules with SBT and IntelliJ IDEA?
body: <p>I'm developing several modules with dependencies among them, and would like to work with them all together in one IDEA project.  I'm using <a href="https://github.com/mpeltonen/sbt-idea" rel="noreferrer">sbt-idea</a> to generate IDEA projects from the sbt build definitions, which works great for individual projects.  In the multiple-module case, however, the things I've tried so far don't quite work:</p>
  
  <p><strong>Use sbt-idea to generate an IDEA .iml file for each module independently</strong>; then create a master IDEA project from scratch an add those modules to it.  This makes the module sources all editable in the same window, but the dependencies among them are not tracked (so trying to navigate from some source within the <em>foo</em> project to something in <em>bar</em> takes me to the imported library version of <em>bar</em>, not the local sources).</p>
  
  <p><strong>Use sbt <a href="https://github.com/harrah/xsbt/wiki/Getting-Started-Multi-Project" rel="noreferrer">multi-project builds</a> (aka subprojects)</strong>, where the parent project's Build.scala contains things like:</p>
  
  <pre><code>lazy val foo = Project(id = "foo", base = file("foo"))
  lazy val bar = Project(id = "bar", base = file("bar")) dependsOn(foo)
  </code></pre>
  
  <p>This almost works, in that sbt-idea generates a master IDEA project with the dependencies among the subprojects tracked.  There are however two caveats: </p>
  
  <ol>
  <li>It seems to be an sbt restriction that the subprojects must live in subdirectories of the master project (i.e., <code>file("../foo")</code> is not allowed). This is not really what I want (what if a module--such as a "utils" or "commons" package--is used in two different master projects?) but I can live with it.</li>
  <li>One of my subprojects has its own subprojects; I'm not sure whether sbt itself deals with these nested projects correctly, but in any case they are ignored by sbt-idea.  Obviously I need nested subprojects to be included recursively in the master project.</li>
  </ol>
  
  <p>To summarize: I'd like to collect modules <em>which may already have subprojects</em> into one big IDEA project with tracked dependencies for convenient editing.  How can I do it?  Thanks!</p>