I have a very large, complicated multi project build, and I am attempting to speed it up by applying the build cache, however, I am finding that task level caching is a little bit too granular for my needs, and wondering how you would recommend caching a subproject’s outputs.
For a concrete example, the subproject in question is a javascript project with a yarn install step, and the output is some resulting javascript files.
My build task declares inputs and outputs, and I can cache it, but it depends on a yarn_install task.
gulp_build {
dependsOn "install_dep"
inputs.dir 'assets'
inputs.dir 'languages'
inputs.dir 'node_modules'
inputs.dir 'src'
inputs.dir 'type-definitions'
inputs.file 'gulpfile.js'
inputs.file 'tsconfig.json'
outputs.dir 'codegen'
outputs.dir 'public'
outputs.cacheIf { true }
}
My first thought was not to declare the node_modules directory as an input, since it itself is a function of package.json and yarn.lock, I could declare them as inputs instead.
Either way, the install_dep task is always executed, so I need to add the node_modules directory to the build cache (which is very large and would still take a long time to download, just to do nothing and be consumed by nothing).
I’m trying to find a way to have a ‘project’ level concept of inputs/outputs, or otherwise force the install_deps step to skip if we’re going to get a cache hit on the build step.
I was imagining a ‘parent task’, which would have inputs and outputs and trigger the ‘child’ tasks if it was executed. This seems to go agains the gradle model of task execution flow control through declaring dependencies, and then evaluating all the dependent tasks first.
What is the ‘gradley’ way to achieve this? Cache the node_modules output even tho I am not using it at all except at build time?
Thanks.