title: Gradle forcefully brings you the incorrect version of Kotlin dependencies
body: <p>There are several questions here on Stackoverflow regarding the Kotlin compiler warning when different versions of Kotlin jars are mixed in the classpath.</p>
  <p>This question is a different one and concerns the situation when you are developing Gradle plugins using Kotlin. When you have at least one of the following:</p>
  <ul>
  <li><code>kotlin-dsl</code> plugin is applied;</li>
  <li><code>java-gradle-plugin</code> plugin is applied;</li>
  <li><code>gradleApi()</code> dependency is added;</li>
  <li><code>gradleKotlinDsl()</code> dependency is added;</li>
  </ul>
  <p>And you have Kotlin plugin like <code>kotlin(&quot;jvm&quot;) version &quot;1.4.10&quot;</code>, e.g.:</p>
  <pre><code>plugins {
      java
      kotlin(&quot;jvm&quot;) version &quot;1.4.10&quot;
      `kotlin-dsl`
      `java-gradle-plugin`
  }
  </code></pre>
  <p>You will get famous:</p>
  <pre><code>w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
  
  bla-bla-bla/gradle-6.7/lib/kotlin-stdlib-1.3.72.jar (version 1.3)
  bla-bla-bla/modules-2/files-2.1/.../kotlin-stdlib-jdk8-1.4.10.jar (version 1.4)
  and so on for every Kotlin jar
  
  w: Consider providing an explicit dependency on kotlin-reflect 1.4 to prevent strange errors
  w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
  </code></pre>
  <p>Here Kotlin 1.3.72 is the embedded version for Gradle 6.7, and Kotlin 1.4.10 is the one you added manually.
  The problem is with <code>gradleApi()</code> or <code>gradleKotlinDsl()</code> because they add Kotlin jars directly as local filesystem files, thus bypassing Gradle dependency versions resolution.</p>