mkrussel
07/13/2022, 4:21 PMbuildSrc
project to configure. It's breaking on applying the kotlin-dsl
plugin.
An exception occurred applying plugin request [id: 'org.gradle.kotlin.kotlin-dsl', version: '2.3.3']
> Failed to apply plugin class 'org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper'.
> Could not create an instance of type org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension.
> Companion
Gradle version: 7.3.3
Kotlin version: 1.7.0
kotlin-dsl version: 2.2 and 2.3.3Caused by: java.lang.NoSuchFieldError: Companion
at org.jetbrains.kotlin.gradle.dsl.ToolchainSupport$Companion.createToolchain$kotlin_gradle_plugin(ToolchainDsl.kt:33)
at org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension.<init>(KotlinProjectExtension.kt:69)
at org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension.<init>(KotlinProjectExtension.kt:109)
at org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension.<init>(KotlinProjectExtension.kt:118)
at org.jetbrains.kotlin.gradle.dsl.KotlinSingleJavaTargetExtension.<init>(KotlinProjectExtension.kt:124)
at org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension.<init>(KotlinProjectExtension.kt:128)
at org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension_Decorated.<init>(Unknown Source)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at org.gradle.internal.instantiation.generator.AsmBackedClassGenerator$InvokeConstructorStrategy.newInstance(AsmBackedClassGenerator.java:2070)
at org.gradle.internal.instantiation.generator.AbstractClassGenerator$GeneratedClassImpl$GeneratedConstructorImpl.newInstance(AbstractClassGenerator.java:488)
at org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator.doCreate(DependencyInjectingInstantiator.java:64)
... 311 more
mbonnin
07/13/2022, 5:05 PMbuildSrc
because Gradle uses something else (1.5 most likely).
Your best bet is to use
plugins {
`embedded-kotlin`
}
or
plugins {
`kotlin-dsl`
}
buildSrc
project separately?
./gradlew -p buildSrc build
mkrussel
07/13/2022, 5:13 PMembedded-kotlin
plugin but still no luck.
When I did revert back to 1.6.21 the warning about incompatible kotlin versions went away, but I still cannot build with 1.7.0.mbonnin
07/13/2022, 5:14 PMbuildSrc
should know nothing about 1.6 vs 1.7buildSrc
, that's most likely the cause of your errormkrussel
07/13/2022, 5:16 PMbuildSrc
but I do use
kotlin("plugin.serialization") version "1.6.21"
in the plugins.mbonnin
07/13/2022, 5:18 PMmkrussel
07/13/2022, 5:18 PMmbonnin
07/13/2022, 5:18 PMbuildSrc/src/main/kotlin/my.convention.gradle.kts
or so?mkrussel
07/13/2022, 5:18 PMmbonnin
07/13/2022, 5:19 PMmkrussel
07/13/2022, 5:19 PMbuildSrc
are .kt
files no .kts
filesmbonnin
07/13/2022, 5:20 PM.kts
files but maybe it's not importantmkrussel
07/13/2022, 5:20 PMmbonnin
07/13/2022, 5:22 PMkotlin-dsl
to embedded-kotlin
and rewrite the convention plugins as regular .kt
files, it might be easier to see where the problem ismkrussel
07/13/2022, 5:24 PMmbonnin
07/13/2022, 5:26 PMmikehearn
07/14/2022, 12:50 PMmbonnin
07/14/2022, 1:01 PMmikehearn
07/14/2022, 1:03 PMmbonnin
07/14/2022, 1:05 PMmbonnin:~/git/demo$ ./gradlew :app:run
> Task :app:run
Hello World! 1.7.0
BUILD SUCCESSFUL in 484ms
mikehearn
07/14/2022, 1:21 PMmbonnin
07/14/2022, 1:22 PMmikehearn
07/14/2022, 1:24 PMmbonnin
07/14/2022, 1:25 PMkotlin-stdlib
in our plugins to avoid exactly that issue. I wrote about it there: https://blog.mbonnin.net/use-latest-kotlin-in-your-gradle-pluginsmikehearn
07/14/2022, 1:27 PMmbonnin
07/14/2022, 1:31 PMmikehearn
07/14/2022, 1:36 PMmbonnin
07/14/2022, 1:36 PM./gradlew -p buildSrc dependencies
, that should show which one is pulling Kotlin 1.7kotlin-reflect
is pulling kotlin-stdlib:1.7.0
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java) {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + "-Xskip-metadata-version-check"
}
}
mikehearn
07/14/2022, 2:01 PMOK - partial success! After removing that reflect line and the three plugins, I can get a build with Kotlin 1.7, woop! Thanks! Unfortunately, re-enabling Dokka and upgrading it to Dokka 1.7.0 brings back the same metadata version mismatch error as before.So it seemed at the time we have to choose between Dokka and Kotlin 1.7, and Dokka is more important. Perhaps there's been a new release since that fixes this.
mbonnin
07/14/2022, 2:02 PMmikehearn
07/14/2022, 2:07 PMmbonnin
07/14/2022, 2:08 PMmikehearn
07/14/2022, 2:08 PMmbonnin
07/14/2022, 2:10 PMmavenCentral()
isn't the same as the dokka:1.7.10 from gradlePluginPortal()
mikehearn
07/14/2022, 2:11 PMIgnat Beresnev
07/14/2022, 4:46 PMmikehearn
07/14/2022, 4:47 PMmbonnin
07/14/2022, 4:54 PMrepositories {
mavenCentral()
gradlePluginPortal {
content {
// Might not even be needed since mavenCentral() should take precedence
excludeGroup("org.jetbrains.dokka")
}
}
}
mikehearn
07/14/2022, 4:58 PMmbonnin
07/14/2022, 4:58 PMIgnat Beresnev
07/14/2022, 5:22 PMmbonnin
07/14/2022, 5:22 PM