gradle-node-plugin
gradle-node-plugin copied to clipboard
npm_install task inputs and outputs
Why are inputs and outputs for npm_install task configured after project is evaluated? I mean this line exactly.
Please have a look at the following log extract:
:frontend:npm_install (Thread[Daemon worker,5,main]) started. :frontend:npm_install Executing task ':frontend:npm_install' (up-to-date check took 0.001 secs) due to: Task has not declared any outputs. Starting process 'command '/project/frontend/.gradle/nodejs/node-v5.10.1-darwin-x64/bin/node''. Working directory: /project/frontend Command: /project/frontend/.gradle/nodejs/node-v5.10.1-darwin-x64/bin/node /project/frontend/node_modules/npm/bin/npm-cli.js install Successfully started process 'command '/project/frontend/.gradle/nodejs/node-v5.10.1-darwin-x64/bin/node'' :frontend:npm_install (Thread[Daemon worker,5,main]) completed. Took 3.835 secs.
With the following piece of code:
project.afterEvaluate {
tasks.npm_install.outputs.dir(file('node_modules'))
}
it finally was marked as up-to-date.
It seams path changed. And why such input and output declared not related to workingDir?
With @Opalo suggested approach I have:
ext.reactAppDir = file("$projectDir/reactapp")
npm_install{
workingDir = reactAppDir
}
project.afterEvaluate { // Bug workaround: @issue https://github.com/srs/gradle-node-plugin/issues/131
tasks.npm_install.inputs.file "${reactAppDir}/package.json"
tasks.npm_install.outputs.dir "${reactAppDir}/node_modules"
tasks.npm_install.outputs.file "${reactAppDir}/package-lock.json"
}
And gradle complains:
> Task :open-area:npmInstall UP-TO-DATE
A problem was found with the configuration of task ':open-area:npmInstall'. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0.
- File '/home/pasha/@Projects/@RLH/portal.java10/open-area/package.json' specified for property '$1' does not exist.