Closed mannodermaus closed 5 years ago
I believe this is not a problem of Kotlin DSL, but this convention. Is it part of kotlin-android plugin feature? If so, better to report it on Kotlin issue tracker
Thanks for the reply. I wasn't sure where this convention is being synthesized, but I do believe that it's added through the kotlin-android
plugin. I'll report it on the Kotlin issue tracker and attach a link here.
Can you please refer to the ticket in the Jetbrains issue tracker?! Thank you :)
I think the issue is somewhere here 😂 https://github.com/JetBrains/kotlin/blob/bd1f95da04c4363cb7f5da4c6a9eef8e6cdca882/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt#L802-L861
I think that the problem with usage of extension function addExtenion
. This function add extension without type:
https://github.com/JetBrains/kotlin/blob/b6102c52b9dac6a258a2add4a4a28571a502692c/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/gradleUtils.kt#L52-L53
Instead, it should be something like this:
internal inline fun <reified T : Any> Any.addExtension(name: String, extension: T) =
(this as ExtensionAware).extensions.add(T::class.java, name, extension)
So in this case extension will be properly typed.
I raised the ticket as KT-31077 on YouTrack now. Added the link to the OP, too!
Fixed in Kotlin 1.3.60 🎉
@eskatos it was fixed in Gradle 5.6, actually: https://youtrack.jetbrains.com/issue/KT-31435.
I tested here with kotlin 1.3.60 and still got the error. When I updated to Gradle 5.6.x, it worked.
YouTrack Issue
After applying the
kotlin-android
plugin, a global configuration closure namedkotlinOptions
becomes available inside theandroid
block. This closure takes one parameter, however it's not strongly typed and resolved toAction<Any>
:Expected Behavior
I can access the implicit
KotlinJvmOptions
directly:Current Behavior
The missing typing prevents us from setting the configuration without a proper cast in place:
Alternatively, we need to configure each task individually:
Your Environment