title: Kotlin + Java 9 modules: Module java.base cannot be found in the module graph
body: <p>I'm having some issues on building a Kotlin project that uses Java 9 features. I know kotlin just allow Java 8 bytecode generation, but acording to <a href="https://kotlinlang.org/docs/reference/whatsnew12.html" rel="noreferrer">kotlinlang.org</a> it should support this functionality since Kotlin 1.2:</p>
  
  <blockquote>
    <p>The Kotlin standard library is now fully compatible with the Java 9
    module system, which forbids split packages (multiple jar files
    declaring classes in the same package).</p>
  </blockquote>
  
  <p>Well, lets to my problem: I'm getting this when I try to execute gradle <code>build</code> task:</p>
  
  <blockquote>
    <p>04:29:27: Executing task 'build'...</p>
    
    <blockquote>
      <p>Task :compileKotlin FAILED e: Module java.base cannot be found in the module graph e: Module java.management cannot be found in the
      module graph</p>
    </blockquote>
    
    <p>FAILURE: Build failed with an exception.</p>
    
    <ul>
    <li><p>What went wrong: Execution failed for task ':compileKotlin'.</p>
    
    <blockquote>
      <p>Compilation error. See log for more details</p>
    </blockquote></li>
    <li><p>Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.</p></li>
    <li><p>Get more help at <a href="https://help.gradle.org" rel="noreferrer">https://help.gradle.org</a></p></li>
    </ul>
    
    <p>BUILD FAILED in 0s 1 actionable task: 1 executed Compilation error.
    See log for more details 04:29:28: Task execution finished 'build'.</p>
  </blockquote>
  
  <p>I searched for that error on Google and found <a href="https://discuss.kotlinlang.org/t/kotlin-support-for-java-9-module-system/2499" rel="noreferrer">this topic</a> where a guy had the same problem, he said he fixed it by targeting a JDK greater than 8, but I'm already with JDK 11 as project SDK and <code>sourceCompatibility</code>.</p>
  
  <p>I'll left some important parts of build.gradle and project structure here to you guys inspect it.</p>
  
  <p>build.gradle</p>
  
  <pre><code>buildscript {
      ext.kotlin_version = '1.3.21'
      ...
  
      repositories { ... }
      dependencies {
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
          classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
      }
  }
  
  plugins {
      ...
  }
  apply plugin: 'java'
  apply plugin: 'kotlin'
  apply plugin: 'application'
  apply plugin: 'maven'
  
  
  group 'io.github.dogobot.core'
  version '4.0.0'
  
  ...
  
  sourceCompatibility = 1.11
  
  repositories {
      mavenCentral()
      jcenter()
      maven { ... }
      maven { ... }
      maven {
          url 'http://maven.ej-technologies.com/repository'
      }
  }
  
  dependencies {
      implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
      implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
      ...
  }
  
  compileKotlin {
      kotlinOptions.jvmTarget = "1.8"
  }
  compileTestKotlin {
      kotlinOptions.jvmTarget = "1.8"
  }
  </code></pre>
  
  <p>module-info.java</p>
  
  <pre><code>module io.github.dogobot.core {
      requires kotlin.stdlib;
      requires kotlin.reflect;
      requires kotlin.logging;
  
      requires java.management;
  
      requires BootingBits;
  }
  </code></pre>
  
  <p>I can run the project with no problems on Intellij Idea, just get this error when executing on gradle.</p>
  
  <p><a href="https://i.stack.imgur.com/dpHta.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dpHta.png" alt="Project Structure"></a></p>