How to get a recent Kotlin version in a multi-project Gradle setup with Kotlin DSL

Viewed 352

Setup

I setup a Gradle multi-project project, including the Kotlin DSL as described on in the Gradle documentation. My Gradle version is 7.4.1, which is the recent version at the time of writing.

In this part of the documentation we are told to use convention plugins for subproject configuration and we should not use subprojects or allprojects DSL.

That is the reason I ended up having

plugins {
    `kotlin-dsl` 
}

in my buildSrc/build.gradle.kts, which is all working as expected.

Problem

By using kotlin-dsl I'm wired to gradle-kotlin-dsl-7.4.1.jar (Gradle version, I mentioned earlier). This jar seems to specify all Kotlin related versions along the project; i.e. I cannot do this to specify my Kotlin version

plugins {
    `kotlin-dsl`

    kotlin("jvm") version "1.6.10" 
    // ...
}

Because two different Kotlin versions will appear

$ ./gradlew build

> Configure project :buildSrc
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.5.31` that might work differently than in the requested version `1.6.10`.

That behaviour and the warning are described here.

Questions

  • Am I able to use a more recent version of Kotlin in this setup, if so: how?
  • Out of curiosity: where do I see the Kotlin version tracked, that is baked into Gradle? I could not find any notice in the last hand full of release notes
1 Answers
  1. atm there is no way to update the embedded version of the Kotlin the kotlin-dsl plugin relies on (github.com/gradle/gradle/issues/16345)
  2. I think your best bet would be the gradle github (github.com/gradle/gradle/issues/19308)
Related