title: Building Kotlin projects with Gradle sometimes fails with NoClassDefFoundError
body: <p>I can't reliably reproduce this problem because it is sporadic. This is what I get when I build a <strong>Kotlin</strong> project with <strong>Gradle</strong>:</p>
  
  <pre><code>Could not perform incremental compilation: Could not connect to Kotlin compile daemon
  Could not connect to kotlin daemon. Using fallback strategy.
  :myproj:compileKotlin FAILED
  1 actionable task: 1 executed
  e: java.lang.NoClassDefFoundError: Could not initialize class kotlin.Unit
  warning: the '-d' option with a directory destination is ignored because '-Xbuild-file' is specified
  Exception in thread "Thread-25" java.lang.NoClassDefFoundError: Could not initialize class kotlin.Unit
      at org.jetbrains.kotlin.compilerRunner.UtilsKt$runToolInSeparateProcess$readErrThread$1$1.invoke(utils.kt)
      at kotlin.io.TextStreamsKt.forEachLine(ReadWrite.kt:154)
      at org.jetbrains.kotlin.compilerRunner.UtilsKt$runToolInSeparateProcess$readErrThread$1.invoke(utils.kt:68)
      at org.jetbrains.kotlin.compilerRunner.UtilsKt$runToolInSeparateProcess$readErrThread$1.invoke(utils.kt)
      at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:18)
  e: java.lang.NoClassDefFoundError: Could not initialize class kotlin.Unit
  ...
  </code></pre>
  
  <p>I run Gradle with the following options</p>
  
  <ul>
  <li><code>gradle assemble --no-daemon --parallel</code></li>
  <li>I tried this within Docker and on my local machine as well (this even happens on the CI server as well)</li>
  <li>this error is completely sporadic I was not able to pinpoint a cause</li>
  <li>it happens with single and multi-module projects as well</li>
  <li>removing the <code>--parallel</code> or adding <code>--daemon</code> option does not help</li>
  <li>I'm using Gradle <code>4.2</code></li>
  </ul>
  
  <p>What could be the problem?</p>