import java.nio.file.Files import java.nio.file.Paths plugins { id("com.github.node-gradle.node") version "3.1.0" } node { // Version of node to use. version = version_nodejs // Version of npm to use. Uses the version included in nodejs if not set. //npmVersion = version_npm // Version of Yarn to use. //yarnVersion = '0.16.1' // Base URL for fetching node distributions (change if you have a mirror). //distBaseUrl = 'https://nodejs.org/dist' // If true, it will download node using above parameters. // If false, it will try to use globally installed node. download = true // Set the work directory for unpacking node //workDir = file("${project.buildDir}/nodejs") // Set the work directory for NPM npmWorkDir = file("${project.buildDir}/npm") // Set the work directory for Yarn //yarnWorkDir = file("${project.buildDir}/yarn") // Set the work directory where node_modules should be located //nodeModulesDir = file("${project.projectDir}") } sourceSets { main { resources { srcDir 'build/generated' } } } npm_run_build.inputs.dir("src").withPropertyName("sourceFiles") npm_run_build.inputs.files(fileTree("src/templates") { include "*.json" include "*.js" include "browserslist" }) npm_run_build.outputs.dir("build/generated").withPropertyName("outputFiles") jar.dependsOn 'npm_run_releasebuild' jar { from 'build/generated/resources' into 'resources' } dependencies { } task createEnvShell { final String cwd = file(".").getAbsolutePath(); final File script = file("env.sh"); final String nodejsPath = "${cwd}/.gradle/nodejs/node-v${version_nodejs}-linux-x64/bin"; final String npmPath = "${cwd}/build/npm/npm-v${version_npm}/bin"; final String nodeModulesBinPath = "${cwd}/node_modules/.bin"; final String content = '#\n# usage: source env.sh'+"\n#\nexport PATH=${nodeModulesBinPath}:${npmPath}:${nodejsPath}:\$PATH\n"; inputs.property("version_nodejs", version_nodejs) inputs.property("version_npm", version_npm) inputs.property("content", content) outputs.file(script) doLast { println 'create environment shell script' Files.writeString(script.toPath(), content); } } tasks['eclipse'].dependsOn createEnvShell