Does anyone know of any gradle plugin compatible w...
# gradle
a
Does anyone know of any gradle plugin compatible with kotlin (kts) that can run node operations? Currently there’s https://github.com/srs/gradle-node-plugin but it’s dependent on Groovy closures
g
but it’s dependent on Groovy closures
It’s unfortunate, and would make sense to ask the author to migrate from Closure to type-safe Action<T> But you still can use this plugin, see official documentation how to use them: https://docs.gradle.org/current/userguide/kotlin_dsl.html#groovy_closures_from_kotlin
a
Thanks. The problem I had was that if I extended one of their classes with kotlin I had to implement some functions (set meta data, etc). I'll have to look more closely to see how that works
g
Why do you extend their class?
In general extending Groovy classes is not pleasant thing, but usually Gradle plugins do not require any inheritance (except cases when you write own plugin and based on their, but usually use public Gradle API is better even for such cases)
a
I’m basically following usage done by apollo android: https://github.com/apollographql/apollo-android/blob/master/apollo-gradle-plugin/src/main/groovy/com/apollographql/apollo/gradle/ApolloCodegenInstallTask.groovy I guess I might be able to avoid extending since its purpose is just to pass some arguments
g
They creation own task by extending NPM task
not really sure that it required, depends on your use case of sure
Anyway it’s possible to do, but not pleasant if you do this not from Groovy, here is a small discussion about it: https://discuss.kotlinlang.org/t/extending-groovy-class-from-kotlin/1675
a
I’m going to try with delegation. It seems like it should work but I still have to run the task. Thanks for the suggestion!
g
but I still have to run the task
Maybe just add it to dependencies of your own task? Which is standard way to compose different tasks, do not extend them, just let them run before or after your task
a
Turns out it was simple enough where I could just use the plugin as is without making my own. 🙂