After updating Dokka from 1.6.21 to 1.7.0 my proje...
# dokka
r
After updating Dokka from 1.6.21 to 1.7.0 my project no longer builds. More info in the thread.
βœ… 1
πŸ‘€ 1
I have this error when compiling
buildSrc
e: /opt/rjaros/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.0/51736992f422993a1e741051bdf3c12801bc1ca1/kotlin-stdlib-common-1.7.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1. e: /opt/rjaros/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.7.0/fbeaa8fa63cbab09c547083a449097be6660a9a/kotlin-stdlib-jdk7-1.7.0.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1. e: /opt/rjaros/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.7.0/362da0b4951ed79a6591743a7fddcfb8c73809f6/kotlin-stdlib-jdk8-1.7.0.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1. e: /opt/rjaros/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.0/a5f42c684ad9003160ef0d0f693ecf0ba7b13549/kotlin-stdlib-1.7.0.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The project is already with Kotlin 1.7.0 and I'm using dokka plugin dependency in my `buildSrc/build.gradle.kts`:
Copy code
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.7.0")
The only change is the dokka version. It builds fine again when returning to 1.6.21.
I usually see some warnings about old Kotlin in gradle classpath when compiling
buildSrc
, but until now there was no problems:
Copy code
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)
I don't know if it is related but I don't have any other old kotlin dependencies in my project.
When I remove dokka-gradle-plugin dependency the incompatibility error is gone but of course my sources don't compile anymore because I'm using dokka classes.
I will be grateful for any advice and ideas πŸ™‚
i
Hi! Yeah, it's an unusual problem, I don't think we have any tests for using Dokka as a dependency in buildSrc. What's your use case if you don't mind me asking, why do you need it there? I'll definitely have a look tomorrow. If it's something we can fix, we'll address it in 1.7.10
r
I just setup dokka across submodules of my project.
I'm using custom configuration so I just wanted to have this in one place instead of 20
i
Overall, the issue might be related to this PR https://github.com/Kotlin/dokka/pull/2521, but we'll need to verify that We introduced the changes because there was incompatibility with the Kotlin compiler version shipped by Gradle, which affected all people who have the same use case as you, but solve it differently: by adding a dependency on
dokka-base
and configuring it in
allprojects {}
or something similar, an example from kotlinx.serialization πŸ™‚ So it looks like we solved the issue for the majority of cases, but it broke your particular case 😞 We'll try to think how to get around that, thanks for reporting it!
j
cc @tapchicoma same issue than serialization right?
πŸ‘Œ 1
as a workaround you can use gradle 7.5-rc-2
πŸ™ 1
βž• 1
r
I'll try
i
Wow, yeah, using
7.5-rc-2
seems to help @Javier is there an issue/thread where I can read more on these changes/problems?
j
basically the problem is that Gradle embedded version doesn't support Kotlin 1.7 and looks like a kotlin plugin is being filtering that version
v
Another workaround:
Copy code
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.7.0") {
    exclude("org.jetbrains.kotlin","kotlin-stdlib-jdk8")
}
πŸ™ 1
This happens due to incompatibility of metadata format. Here is more detail description of the workaround. In your case we have Gradle 7.4.2 with embedded Kotlin version 1.5.31 that can not read metadata 1.7 of stdlib from Dokka.
m
Does dokka and all transitive dependencies compile with
apiVersion = 1.5
? If not, upgrading Gradle seems like a safer bet to avoid runtime crashes. (edit: the link above seems to indicate that dokka is indeed compiled for
1.4
but says nothing about the transitive dependencies)
Thinking more about this, have you ever considered declaring
kotlin-stdlib
as a
compileOnly
dependency? The Kotlin plugin does this (cf https://youtrack.jetbrains.com/issue/KT-41142/Kotlin-version-conflict-when-using-Kotlin-Gradle-plugins-in-pre-compiled-script-plugin#focus=[…]69.0-0)
πŸ€” 1
j
I'm facing the same issue. Same setup: I depend on Dokka in
buildSrc
to share configuration between subprojects in https://github.com/joffrey-bion/krossbow. Will try with Gradle 7.5-rc
i
JFYI: If everything's well, Martin's fix will be released in
1.7.10
in about 2 weeks or so.
πŸ™ 3
πŸ‘ 3
j
Thanks for your reactivity!