title: Use Gradle sub-projects with Kotlin multiplatform
body: <p>I'm using Kotlin multi-platform (JVM &amp; JS), which in IDEA creates three projects: <code>demo</code>, <code>demo-js</code> and <code>demo-jvm</code>.</p>
  
  <p>I would like to split the common code into more subprojects/submodules. Let's say I add <code>commonmod</code>; how do I make it compile?</p>
  
  <p>The error right now, for <code>gradle run -p demo-jvm</code>, is:</p>
  
  <pre><code>demo/demo-js/src/main/kotlin/demo/commonmod/example.kt: (3, 12): Actual function 'getPlatform' has no corresponding expected declaration
  </code></pre>
  
  <p>but I think I'm doing this fundamentally wrong, as I don't know what should depend on what (although I tried quite some iterations). If I solve this error I get other ones, and then other ones again, until I'm back to this one.</p>
  
  <hr>
  
  <p>As a minimal-but-still-large <a href="https://github.com/mverleg/kotlin_multiplatform_gradle_demo" rel="noreferrer">example</a>, I have:</p>
  
  <p><em>demo/settings.gradle</em>:</p>
  
  <pre><code>rootProject.name = 'demo'
  
  include 'demo-jvm', 'demo-js', 'commonmod'
  </code></pre>
  
  <p><em>demo/build.gradle</em>:</p>
  
  <pre><code>buildscript { ... }
  
  apply plugin: 'kotlin-platform-common'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
      testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
      testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
      compile project(':commonmod')
  }
  </code></pre>
  
  <p><em>demo/demo-jvm/settings.gradle</em>:</p>
  
  <pre><code>rootProject.name = 'demo'
  </code></pre>
  
  <p><em>demo/demo-jvm/build.gradle</em>:</p>
  
  <pre><code>buildscript { ... }
  
  apply plugin: 'kotlin-platform-jvm'
  apply plugin: 'application'
  
  repositories {
      mavenCentral()
  }
  
  mainClassName = "demo.MainKt"
  
  dependencies {
      compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
      expectedBy project(":")
      testCompile "junit:junit:4.12"
      testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
      testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
  }
  </code></pre>
  
  <p><em>demo/demo-js/settings.gradle</em>:</p>
  
  <pre><code>rootProject.name = 'demo'
  </code></pre>
  
  <p><em>demo/demo-js/build.gradle</em>:</p>
  
  <pre><code>buildscript { ... }
  
  apply plugin: 'kotlin-platform-js'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
      expectedBy project(":")
      testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
  }
  </code></pre>
  
  <p><em>demo/commonmod/settings.gradle</em>:</p>
  
  <pre><code>rootProject.name = 'demo'
  
  include 'demo-jvm', 'demo-js'
  </code></pre>
  
  <p><em>demo/commonmod/build.gradle</em>:</p>
  
  <pre><code>buildscript { ... }
  
  apply plugin: 'kotlin-platform-common'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
      testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
      testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
      compile project(':demo-js')
      compile project(':demo-jvm')
  }
  </code></pre>