dokka icon indicating copy to clipboard operation
dokka copied to clipboard

[1.7.0] Runtime JAR files in the classpath should have the same version

Open IgnatBeresnev opened this issue 2 years ago • 1 comments

Build fails if Dokka is used as a dependency in buildSrc, initially reported in the community slack: link to message

The same problem is relevant for kotlinx.serialization.

Workarounds

  • Update to Gradle 7.5-rc-2, it will solve the problem
  • Exclude stdlib:
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.7.0") {
    exclude("org.jetbrains.kotlin","kotlin-stdlib-jdk8")
}

Fix

Should hopefully be solved by https://github.com/Kotlin/dokka/pull/2543 in 1.7.10, will post updates here.

Stacktrace

w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /opt/rjaros/.gradle/wrapper/dists/gradle-7.4.2-all/9uukhhbclvbegdvsww0j0cr3p/gradle-7.4.2/lib/kotlin-stdlib-1.5.31.jar (version 1.5)
    /opt/rjaros/.gradle/wrapper/dists/gradle-7.4.2-all/9uukhhbclvbegdvsww0j0cr3p/gradle-7.4.2/lib/kotlin-stdlib-common-1.5.31.jar (version 1.5)
    /opt/rjaros/.gradle/wrapper/dists/gradle-7.4.2-all/9uukhhbclvbegdvsww0j0cr3p/gradle-7.4.2/lib/kotlin-stdlib-jdk7-1.5.31.jar (version 1.5)
    /opt/rjaros/.gradle/wrapper/dists/gradle-7.4.2-all/9uukhhbclvbegdvsww0j0cr3p/gradle-7.4.2/lib/kotlin-stdlib-jdk8-1.5.31.jar (version 1.5)
    /opt/rjaros/.gradle/wrapper/dists/gradle-7.4.2-all/9uukhhbclvbegdvsww0j0cr3p/gradle-7.4.2/lib/kotlin-reflect-1.5.31.jar (version 1.5)

IgnatBeresnev avatar Jun 21 '22 16:06 IgnatBeresnev

Apparently, this is still happening for Dokka 1.7.10 which is downloaded from gradlePluginPortal(), but it doesn't happen to Dokka 1.7.10 downloaded from mavenCentral(). For some reason, Dokka's .pom file differs for these two repositories, even though it was published not only from the same branch/commit, but from the same build.

Workarounds:

  1. Get Dokka from mavenCentral(). If it's first on the list, it should be given a priority, but you can still exclude from gradlePluginPortal() just in case or if you don't want to change the order.
repositories {
    mavenCentral()
    gradlePluginPortal {
        content {
            // Might not even be needed since mavenCentral() should take precedence
            excludeGroup("org.jetbrains.dokka")
        }
    }
}
  1. Use Gradle 7.5, which can now read Kotlin 1.7 metadata, so the error should be gone.

There's a follow up PR with an attempt to fix it: #2570

IgnatBeresnev avatar Jul 15 '22 13:07 IgnatBeresnev

We haven't seen this problem for a while, no new reports or anything that would indicate it hasn't been resolved, so I'll close the issue as fixed for now.

Let us know if it still affects you.

IgnatBeresnev avatar Sep 01 '23 15:09 IgnatBeresnev