title: Converting Gradle/IDEA project into multiple subprojects
body: <p>I have an <a href="https://github.com/hotmeatballsoup/intellij-scala-gradle-example" rel="nofollow noreferrer">IntelliJ IDEA (Community Edition 2016.2) project</a> that was created by importing a file system project that had a <code>build.gradle</code> and <code>settings.gradle</code> defined inside its root. When I open it in IDEA everything is working nicely.</p>
  
  <p>As you can see on GitHub, the basic project directory structure is currently:</p>
  
  <pre><code>intellij-scala-gradle-example/
      src/
        main/
            scala/
            resources/
        test/
            scala/
            resources/
      build.gradle
      settings.gradle
  </code></pre>
  
  <p>I now want to convert this project into 3 smaller subprojects so that the project directory structure <em>something</em> like:</p>
  
  <pre><code>intellij-scala-gradle-example/
      client/
          src/
            main/
                scala/
                resources/
            test/
                scala/
                resources/
      shared/
          src/
            main/
                scala/
                resources/
            test/
                scala/
                resources/
      server/
          src/
            main/
                scala/
                resources/
            test/
                scala/
                resources/
      build.gradle
      settings.gradle
  </code></pre>
  
  <p>I can handle running all the <code>mkdir</code>s on the command-line and physically restructuring the directories on the file system, but I'm not sure:</p>
  
  <ul>
  <li>What I need to do so that Gradle understands that I now have these 3 <code>client/</code>, <code>shared/</code> and <code>server/</code> sub-projects; and</li>
  <li>I'm not sure what I need to do so that IDEA picks up all of these changes and compiles things correctly</li>
  </ul>
  
  <p>Obviously, any classes (under <code>shared/src/main/scala</code>) or resources (under <code>shared/src/main/resources</code>) in the "shared" project should be visible to <code>client/</code> and <code>server/</code>. But the client should never be able to "see" server classes/resources and vice versa.</p>
  
  <p><strong>Any idea (no pun intended) how I could accomplish this, and what the order of events are here?</strong></p>
  
  <hr>
  
  <p><strong>Update:</strong> This screenshot shows the subprojects added to the project but IDEA not seeing them as Scala subprojects (I'm unable to add packages and Scala sources to any of the subprojects).</p>
  
  <p><a href="https://i.stack.imgur.com/YfCM0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YfCM0.png" alt="enter image description here"></a></p>