This message was deleted.
# kotlin-dsl
s
This message was deleted.
n
I'm not sure if there's a separate changelog for the plugin, as it's bundled in the main gradle release. Its documentation is located here: https://docs.gradle.org/current/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin
ł
🤔 asking because I see updates to that plugin independent from Gradle releases. For example 3.2.2 was released on November 30, 3.2.3 and 3.2.4 were released in December. Last Gradle release was on November 25
n
interesting 🤔 Not sure what the separate releases mean then. The following implies that the plugin is definitely the bundled one, given the id. https://github.com/gradle/gradle/blob/master/build-logic/kotlin-dsl/src/main/kotli[…]kotlindsl/generator/tasks/GenerateKotlinDependencyExtensions.kt I'll have to defer to someone with more insights in that case 🙂
p
This plugin is tied to the Gradle version. You should not try to use a version on your own but instead use the blessed version for a given Gradle version. That's what the warning says when you are not using the blessed version. There have been new versions published because we are making changes to the Kotlin DSL that require a new plugin version, e.g. upgrading the embedded Kotlin for the next Gradle version.
ł
🤔 So maybe I’m doing something wrong, but generally I just wanted to use the kotlin-dsl extensions in my
build-src
, so I just have a
Copy code
plugins {
    id "org.gradle.kotlin.kotlin-dsl" version "3.2.2"
}
there, and dependabot suggests updates 😅
p
Arf dependabot 😵‍💫
We should expose this publicly but you can use
org.gradle.kotlin.dsl.support.KotlinDslPluginsKt.getExpectedKotlinDslPluginsVersion()
to get the blessed version
ł
🤔 but in
plugins
block I can’t refer to properties, right? And even then it looks like this property is in
gradle-kotlin-dsl-7.6.jar
, should I have access to it before applying
kotlin-dsl
plugin?
n
can't you just use the
kotlin-dsl
accessor, instead of defining the full id and version?
p
Ah right 🤦‍♂️ And this is a Groovy script
ł
This is a groovy script, and I want to use Kotlin DSL extensions in
build-src/src/main/kotlin
. I may as well be doing something completely wrong, I’d actually like to get by without any additional plugins and just import the extensions as a regular library dependency but I didn’t find any artifact with them
p
Ok. You don't need the
kotlin-dsl
plugin for that. You can do:
Copy code
dependencies {
    implementation(ProjectExtensionsKt.gradleKotlinDsl())
}
👀 1
ł
Unfortunately I get quite a lot of compilation errors with that dependency, I guess it’s because I’m using some extensions generated for external dependencies as well? Although it seems to be failing for stuff like
repositories { exclusiveContent forRepository …
, perhaps because without the plugin I’d need to use
it
parameter and not receiver?
p
Yes, the plugin also applies the "sam with receiver" compiler plugin that remove the need to use
it
👍 1
ł
I got back to this thing, I realized I also have sam-with-receiver plugin applied explicitly, but still see the issue. I noticed that the plugin depends on annotations to know which functions to transform, so it looks like I can’t get the receivers without the kotlin-dsl plugin or I’m missing something?
Got it 🙂
Copy code
samWithReceiver {
  annotation("org.gradle.api.HasImplicitReceiver")
}
👍 1