I have a gradle 8 composite build with a build-log...
# community-support
t
I have a gradle 8 composite build with a build-logic (kotlin-dsl plugin) project. In my extension object i would like to access my convention plugin instance. However the following line says its incompatible with gradle 9:
Copy code
abstract class MyConventionExtension(private val plugin: Convention_gradle) {
This seems to be caused by the KotlinBuildScript class being deprecated in favor of KotlinProjectScriptTemplate. I however cant find a way to switch the compilation of the convention.gradle.kts file to use the newer base-class. Is there a property i can set or do i just have to live with that deprecation for now?
a
I however cant find a way to switch the compilation of the convention.gradle.kts file to use the newer base-class.
You'll have to wait until Gradle updates its embedded Kotlin to 2.0 https://github.com/gradle/build-tool-roadmap/issues/63
I think it's a little unusual to pass the plugin into the extension, but it's still valid, it's just a personal opinion. Usually the extension is just a container for configuration, and the plugin uses the extension to drive its own logic.
t
I would have expected a replacement to exist, before Gradle 9. K2 will probably take a major to switch to and the KotlinBuildScript class is annotated to be removed in G9. But im taking that, as the switch from KotlinBuildScript to KotlinProjectScriptTemplate for kotlin-dsl projects has not been implemented yet. As for the weirdness of what im doing: Im trying to keep the extension as an API, and keep the method implementations in my Plugin class/script.
v
Maybe consider using a "normal* class to implement your plugin instead of a precompiled script plugin, then you should not have that problem. I personally consider the class that results from a script compilation more as an implementation detail that you should not reference explicitly, but that might just be me. You could also give the logic as separate function types into the extension instead of the plugin class, or have a class with those methods in your precompiled script plugin that you then give to the extension.
👍 1