This message was deleted.
# community-support
s
This message was deleted.
v
Copying here from the Kotlin slack for readers here. You shouldn't, but instead add an extension to the handler where you want to have that. If you for example have in the plugin
Copy code
abstract class Foo {
    fun bar() {
        println("bar")
    }
}
f
(repositories as ExtensionAware).extensions.create<Foo>("foo")
then you can do downstream for example:
Copy code
repositories {
    foo.bar()
}
or
Copy code
repositories {
    foo {
        bar()
    }
}
and in both, Groovy DSL and Kotlin DSL
j
@Vampire Is there a way to get typings on this?
This is on build.gradle files, it works correctly on .kts files
v
What do you mean exactly? Do you mean type-hints / IntelliSense by IDE?
I don't think you can get them in Groovy build scripts, which is one of the big pros of the Kotlin DSL, the amazingly better IDE support when using a good IDE like IntelliJ
Maybe you could achieve something using GDSL files, but I don't know. Never really used them, especially not in combination with Gradle. I don't know whether IntelliJ would even look at them in that case.
j
Thanks for the insightful reply! And I agree with you and wish that we could just use Kotlin DSL. But there are the skeptics who refuse to use it /shrug I am already using IntelliJ Ultimate and not getting completions for it, but maybe I just shouldn't care and tell the Kotlin skeptics to adopt or die:)
v
I am already using IntelliJ Ultimate and not getting completions for it
Yes, what I said. You will not get completions which is why Kotlin DSL is so much better. You can research about GDSL files and whether they might maybe work. But honestly, the better invest would be to make those sceptics die. 😄
You immediately get typesafe build scripts, helpful error messages if you mess up the syntax opposed to the non-saying messages you often get with Groovy DSL, and that amazingly better IDE support.
And if they are concerned about performance, there are cases where Groovy DSL is faster, there are cases where Kotlin DSL is faster. And the points above mitigate a thousand times the loss of speed in some areas. And hopefully with K2 compiler the speed difference even gets smaller or swapped.
186 Views