Welcome to the forums and thanks for reaching out. It’s not possible at the moment to skip the download. Netlify will install all dependencies, languages and frameworks that your project might need and only then proceed to the build command.
This works fine for a lot of people, could you please explain what your use case is that won’t work fine with this workflow?
During build when a dependency isn’t found in the cache, it should of course be downloaded.
But on subsequent builds, I would expect Java dependencies to be cached (in the .m2 directory), in a similar manner to how it is done for Node dependencies (in the node_modules directory).
Node doesn’t need to re-download dependencies already available in the cache (node_modules directory) while Java does.
The thing I don’t understand is, that when I manually inspect the contents of $NETLIFY_BUILD_BASE/cache/.m2, I can see cached Java dependencies from the last successful build. But they aren’t leveraged because the $HOME/.m2/ (where Java expects to be able to read and write its dependencies) is nearly empty.
My builds work (as in my sites are put live correctly), but I suspect that a bit of unnecessary build minutes is wasted due to the cache not being leveraged.
I am almost certain caching of Java dependencies used to work.
Could try modifying your build process to copy the contents of the $NETLIFY_BUILD_BASE/cache/.m2 directory to the $HOME/.m2 directory before running the build? If the subsequent build completes faster, then it’s likely that Netlify is using a separate cache for each build.
From my understanding it’s a risk to include cache files from a previous build, so we build in a new environment every time. You can configure your build though to cache certain files every time but that’s up to you.