https://kotlinlang.org logo
#gradle
Title
d

David Herman

07/27/2023, 12:52 AM
Can I write a Gradle Plugin right now using Kotlin 1.9.0?
I'm using the
kotlin-dsl
plugin, so I'm guessing I need to wait for https://docs.gradle.org/current/userguide/compatibility.html#kotlin to get updated?
c

Chris Lee

07/27/2023, 12:54 AM
Correct. Currently Gradle doesn’t support Kotlin 1.9. Gradle 8.3 is @ rc1 and will support Kotlin 1.9.0. https://docs.gradle.org/8.3-rc-1/userguide/compatibility.html
d

David Herman

07/27/2023, 12:54 AM
Oh hello here as well @Chris Lee
c

Chris Lee

07/27/2023, 12:54 AM
Hello! Is there anything in 1.9.0 that you are specifically looking for related to plugins?
d

David Herman

07/27/2023, 12:55 AM
Nope, I just want to upgrade my project in general to 1.9.0, and I'm running into trouble with the Gradle plugin modules
I removed the
kotlin("jvm")
plugins that you pointed out and am only using
kotlin-dsl
right now, but I'm still getting the same compile error
so I'm guessing
kotlin 1.9.0
is leaking in somehow
c

Chris Lee

07/27/2023, 12:56 AM
Check the dependencies in your build file for the plugin, make sure kotlin isnt in there as well.
d

David Herman

07/27/2023, 12:56 AM
I'm seeing this warning for example:
Copy code
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.8.20` that might work differently than in the requested version `1.9.0`.
Likely I'm pulling it in from some other dep in my code
c

Chris Lee

07/27/2023, 12:57 AM
yep
d

David Herman

07/27/2023, 12:57 AM
OK, sounds like I should wait for Gradle 8.3, that's the easiest
c

Chris Lee

07/27/2023, 12:57 AM
run a build scan (paste link if you can), easy to track it down from there.
You likely want to fix this - coupling your build environment Kotlin version to app kotlin version is not desireable.
d

David Herman

07/27/2023, 12:58 AM
Doing that now -- I'm sure I'll see Kotlin 1.9.0 referenced in the scan
I normally avoid coupling but this is a Compose project, which is why when I upgrade the Compose version I also need to upgrade the Kotlin version
c

Chris Lee

07/27/2023, 12:58 AM
this is suspect:
implementation(kotlin("stdlib"))
and perhaps this:
implementation(kotlin("gradle-plugin"))
d

David Herman

07/27/2023, 12:59 AM
So my Gradle plugin is actually parsing user code
c

Chris Lee

07/27/2023, 12:59 AM
and maybe this:
api(kotlin("compiler-embeddable"))
d

David Herman

07/27/2023, 12:59 AM
Might be time to move to ksp
I couldn't use it when the project started
since it wasn't ready for js-ir yet
c

Chris Lee

07/27/2023, 1:00 AM
oh ugh, yea, that’s a challenge.
d

David Herman

07/27/2023, 1:02 AM
https://scans.gradle.com/s/3rkiizd2tsjvi there's the scan, but no need to look into it unless you're curious. I can take it from here for now.
Thanks for your help, again!
a

Adam S

07/27/2023, 7:29 AM
good to see your question is solved, and just to add: hopefully the “how to write a Gradle plugin in Kotlin” docs will be improved soon https://github.com/gradle/gradle/pull/24286 🤞
🙌 1
10 Views