Does anyone know how to write in groovy the equiva...
# javascript
g
Does anyone know how to write in groovy the equivalent of
Copy code
rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class.java) {
    rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "..."
}
v
Should be something like
Copy code
rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin) {
    rootProject.kotlinNodeJs.nodeVersion = "..."
}
BUT you should not use
Project#plugins
as its JavaDoc tells, but instead either
PluginAware
methods on
Project
directly, or
Project#pluginManager
g
The answer:
Copy code
rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin) {
    rootProject.extensions.getByType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension).nodeVersion = "..."
}
See: https://youtrack.jetbrains.com/issue/KT-44541#focus=Comments-27-5707083.0-0
v
And my version did not work? As Groovy is duck-typed and the extensions can be queried dynamically, it should work. Besides the misuse of
Project#plugins
👌 1
g
Yes, your version works and is easier to read. 🙏
👌 1