buildscript { repositories { mavenCentral() maven { url 'https://plugins.gradle.org/m2/' } } dependencies { classpath "com.github.node-gradle:gradle-node-plugin:3.2.1" } } plugins { // Apply the java plugin to add support for Java id 'base' id "com.github.node-gradle.node" version "3.2.1" // gradle-node-plugin } node { /* gradle-node-plugin configuration https://github.com/srs/gradle-node-plugin/blob/master/docs/node.md Task name pattern: ./gradlew npm_ Executes an NPM command. */ // Version of node to use. version = '16.13.1' // Version of npm to use. npmVersion = '8.1.2' // If true, it will download node using above parameters. // If false, it will try to use globally installed node. download = true } npm_run_build { // make sure the build task is executed only when appropriate files change inputs.files fileTree('public') inputs.files fileTree('src') // 'node_modules' appeared not reliable for dependency change detection (the task was rerun without changes) // though 'package.json' and 'package-lock.json' should be enough anyway inputs.file 'package.json' inputs.file 'package-lock.json' outputs.dir 'build' } // declare a dedicated scope for publishing the packaged JAR configurations { npmResources } configurations.default.extendsFrom(configurations.npmResources) assemble.dependsOn npm_run_build