The problem is basically the way the YarnTask is configured: in its constructor, a project.afterEvaluate hook is registered to setup the working dir of the task in order to use the setup node.nodeModulesDir
However that hook is not always called, especially not when the task is created after the project was evaluated (probably because at this point you can no longer register after evaluation blocks)
The problem is basically the way the YarnTask is configured: in its constructor, a project.afterEvaluate hook is registered to setup the working dir of the task in order to use the setup node.nodeModulesDir
However that hook is not always called, especially not when the task is created after the project was evaluated (probably because at this point you can no longer register after evaluation blocks)
Here's a simple reproduction script:
Now, here my use case is that i have 1 scripts in my package.json called somescript. somescript requires some setup so it is referenced in the build.
If you simply run gradle on that script you'll see:
But now if you no longer need any setup on the yarn_somescript task and remove it from the build, then re-running will yield:
A simple workaround is to simply reference them in the build. But it's still a workaround :-)