Why Gradle resolve dependencies download so slow
When building a Gradle project with only one unresolved dependency(1.18M, h2-1.3.148), it stuck at 8% progress and stay there forever. I don't think it's the problem Internet connection speed, because even it's slow, it should not take that long to download just one Jar.
I guess it just stopped there, and there are no time out mechanism, it happens in Java HttpClient library, if you don't set the timeout it will wait forever even the sever already stopped responding. As pointed out in Java InputStream read hangs forever and how to fix it with timeout and retry in Clojure
Then I tried to download the url directly with other file download tool such as wget
It's slow too, and the speed drops to zero when download progressed half. So the problem is the server at repo1.maven.org is slow. For some Jars, it won't let you fully download the file in one shot.
With a GUI download tool I can pause the download and resume it and successfully download it, but I can't do this in Gradle, If I interrupt the build and restart it, it will download the file from the beginning and hangs again.
There is a solution for this, if everything else has been downloaded except the Jar and you have the Jar in other place, you can just copy the file to Gralde's cache folder, in my case it's
There should be a POM file but the Jar is missing, so copy the file over there and restart Eclipse. It should work now.
If you refresh Gradle, it will try to download the source Jar, the problem may show again, just do the same thing to the source Jar. The source Jar should be put into another folder under
Gradle will create it for you.
The situation I observed about downloading from repo1.maven.org: the download starts very slow, when it goes to 30% or 50%, speed goes to zero, pause and then resume the downloading will reactivate it, it can repeat several times to fully download the file. But Gradle's downloading mechanism can't handle this situation, so it hangs forever.