We run gradle builds within docker containers (the reason for that is the build requires software we don't want to install on the host; node, wine etc. Not even java or gradle is installed on the host).
Launching each container with an empty cache is annoying slow.
I've set up gradle-4.0's http build cache. That avoided the need to java-compile in most cases. The performance gain is though quite low, because build-time is dominated by downloading dependencies. gradlew --parallel helped to mitigate that a bit, but to really boost the build, downloading should be avoided altogether.
Sharing ~/.gradle as a docker volume is problematic, because it will cause contention when containers run in parallel (https://github.com/gradle/gradle/issues/851).
So, what else can be done to avoid downloading the same artifacts over and over again?