Home > Software engineering >  How to configure all subprojects that are using NodePlugin in Gradle
How to configure all subprojects that are using NodePlugin in Gradle

Time:08-14

I have a multi-project, and a few of its subprojects use the Gradle Plugin for Node.

./subproject/build.gradle:

// GitHub: https://github.com/node-gradle/gradle-node-plugin
plugins {
    id "com.github.node-gradle.node" version "3.4.0"
}
// ...

I would now like to configure all of these subprojects from the root build.gradle.

./build.gradle

pluginManager.withPlugin('what.do.i.put.here') {
    node {
        download = true
    }
    // ...
}

Now my question: What do I have to put in as parameter for withPlugin? Where do I find the "official" plugin name to use?

CodePudding user response:

Instead of using the pluginManager I found the following way to achieve this:

// This is executed on all subprojects
subprojects {
    // This is executed on all subprojects that use the NodeJS plugin (https://github.com/node-gradle/gradle-node-plugin - npm_<...> (e.g., npm_install))
    plugins.withId('com.github.node-gradle.node') {
        node {
            download = true
        }

It uses plugins.withId inside of subprojects, using the ID also specified in the plugins section: com.github.node-gradle.node

  • Related