Slackbot
09/29/2022, 3:18 PMJavi
09/29/2022, 3:28 PMkotlin-dsl
is using org.jetbrains.kotlin:kotlin-sam-with-receiver
with the version 1.7.10
, so it is not building due being incompatible with the new update of Kotlin 1.7.20
Fleshgrinder
09/29/2022, 3:35 PMkotlin-dsl
is also incompatible with 1.7.10
as it uses an older version. And, no, it's not possible, because it needs to be resolved and included in the plugins classpath. It's like using Groovy 4 in Groovy 3, or Java 18 in Java 8.Javi
09/29/2022, 3:35 PMJavi
09/29/2022, 3:36 PM3.1.0
Javi
09/29/2022, 3:37 PMorg.jetbrains.kotlin:kotlin-sam-with-receiver
with the version 1.7.20
, which is annoyingJavi
09/29/2022, 3:37 PMFleshgrinder
09/29/2022, 3:40 PM1.6.21
, that is 2.3.3
of the kotlin-dsl
. Including 3.1.0
in your dependencies is not changing that, it just leads to more incompatibility whenever your plugin is included in any Gradle build. Until a new Gradle version is released with the updated kotlin-dsl
that is.Javi
09/29/2022, 3:41 PMFleshgrinder
09/29/2022, 3:46 PMbuild.gradle.kts
println(org.gradle.kotlin.dsl.embeddedKotlinVersion)
println(org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion)
The caveat is that the plugin you build is now tied to Gradle releases that contain a compatible Kotlin version. This can get hairy very quickly, since Kotlin evolves extremely fast and does not have the stability of Java: https://kotlinlang.org/docs/kotlin-evolution.html
That said, if you are willing to simply always require latest of everything, and update your things in a timely manner than you can easily build Kotlin libraries and plugins that are Gradle compatible.
gradle-compatible-kotlin-library/build.gradle.kts
plugins {
kotlin("jvm") version embeddedKotlinVersion
}
gradle-compatible-kotlin-plugin/build.gradle.kts
plugins {
`kotlin-dsl`
}
gradle-compatible-plugin-that-applies-the-kotlin-dsl/build.gradle.kts
import org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion
plugins {
`kotlin-dsl`
}
dependencies {
api("org.gradle.kotlin:gradle-kotlin-dsl-plugins:$expectedKotlinDslPluginsVersion")
}
Javi
09/29/2022, 3:48 PMFleshgrinder
09/29/2022, 3:48 PMFleshgrinder
09/29/2022, 3:50 PMinline
for anything it's going to result in an error on the consumer of your plugin.
Fun fact: Gradle itself is still built against Java 6. 😛Javi
09/29/2022, 3:54 PMFleshgrinder
09/29/2022, 3:57 PMkts
scripts (e.g. build.gradle.kts
, settings.gradle.kts
) with jvmTarget = 8
and if a plugin is compiled with e.g. jvmTarget = 11
certain Kotlin features start to fail since they cannot be compiled. Most prominent (and maybe even the only feature 🤷 ) is inline
. The error message you get is cannot inline bytecode 11 into 8
(or similar).
You can still use dependencies and libraries that target greater Java versions, given that all users of your plugin know that they have to run the Gradle build with a newer Java version.Fleshgrinder
09/29/2022, 3:59 PMJavi
09/29/2022, 4:02 PMFleshgrinder
09/29/2022, 4:04 PMJavi
09/29/2022, 4:05 PMFleshgrinder
09/29/2022, 4:08 PMJavi
09/29/2022, 4:15 PMFleshgrinder
09/29/2022, 4:16 PMJavi
09/29/2022, 4:21 PMFleshgrinder
09/29/2022, 4:22 PM