Gradle not finding cached dependencies offline

I’m working behind a firewall that blocks many repositories. I’m trying to run a Gradle build in a Docker image created from the .gradle directory.

Image for reference:

If I run the container I can cd into /gradle_cache/.gradle and see /caches, which contains modules-2 and files-2.1 as expected. I can also find dependencies in there.

I set the GRADLE_USER_HOME env variable to /gradle_cache/.gradle and then try running ./gradlew build --offline.

The output from that is a whole list of “Could not download xxx. No cached version available for offline mode”. Which is frustrating, because I can see it in the cache.

Is there any way to debug why this is happening?

I’m seeing exactly the same issue. I’m trying to optimize my gradle build and I’d like to run one step to run check, which will resolve dependencies, but then, I want to use docker with volumes to assemble.

While working in the docker container I can see that /root/.gradle/

root@5d8005fd10b0:/app# ls /root/.gradle/
build-scan-data  caches  daemon  native  notifications  workers  wrapper

And inside caches I can find all the jar files that my app needs, but if I run gradle assemble --offline it gives error saying it cannot find any dependency.