I have a module containing convention plugins and ...
# gradle
a
I have a module containing convention plugins and I'm applying
kotlin-dsl
plugin to the module. When I try to use
Enum.entries
in the module, I get two errors: • The feature "enum entries" is only available since language version 1.9 • This declaration needs opt-in. Its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)' Even if I add
@OptIn(kotlin.ExperimentalStdlibApi::class)
, the first error still persists. But if I use
embedded-kotlin
instead of
kotlin-dsl
, the errors go away. Any reasons why? I'm using Gradle 8.6 and the bundled Kotlin version is 1.9.20.
v
It is for backward compatibility: target 1.8 enables running the generated plugin with Gradle 8.0+
v
Gradle 9 likely will increase the language version to 1.9 or whatever is current by then.
a
Understood. Thank you!
👌 1
m
If it's convention plugins that are not published, you don't really care about compatibility with other versions of Gradle, you can safely override that. This post is a bit old but still applies: https://handstandsam.com/2022/04/13/using-the-kotlin-dsl-gradle-plugin-forces-kotlin-1-4-compatibility/
👍 1
v
Except for one detail, starting with Gradle 8.1 you do not
afterEvaluate
anymore as also that plugin is not using it anymore since then. :-)
👍 1
m
OMG yes
afterEvaluate{}
needs to die blob upside down !
👆 1