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

Albert Chang

03/13/2024, 2:57 AM
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

vladimirsitnikov

03/13/2024, 4:31 AM
It is for backward compatibility: target 1.8 enables running the generated plugin with Gradle 8.0+
v

Vampire

03/13/2024, 9:07 AM
Gradle 9 likely will increase the language version to 1.9 or whatever is current by then.
a

Albert Chang

03/13/2024, 9:17 AM
Understood. Thank you!
👌 1
m

mbonnin

03/13/2024, 9:41 AM
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

Vampire

03/13/2024, 2:16 PM
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

mbonnin

03/13/2024, 2:19 PM
OMG yes
afterEvaluate{}
needs to die blob upside down !
👆 1
10 Views