Gradle wrapper does not follow redirects

I just tried building Apache Kafka project, trunk branch. It has Gradle wrapper configured to fetch Gradle 1.6 from

distributionUrl=http://services.gradle.org/distributions/gradle-1.6-bin.zip

Build fails with following exception:

C:\Users\foo\Documents\GitHub\kafka> .\gradlew jarAll Downloading http://services.gradle.org/distributions/gradle-1.6-bin.zip

Unzipping C:\Users\foo.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\gradle-1.6-bin.zip to C:\Users\foo.gradle\wrapper\dist s\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok Exception in thread “main” java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file

at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)

at org.gradle.wrapper.Install.createDist(Install.java:44)

at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)

at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:58) Caused by: java.util.zip.ZipException: error in opening zip file

at java.util.zip.ZipFile.open(Native Method)

at java.util.zip.ZipFile.(ZipFile.java:215)

at java.util.zip.ZipFile.(ZipFile.java:145)

at java.util.zip.ZipFile.(ZipFile.java:159)

at org.gradle.wrapper.Install.unzip(Install.java:157)

at org.gradle.wrapper.Install.access$400(Install.java:26)

at org.gradle.wrapper.Install$1.call(Install.java:67)

at org.gradle.wrapper.Install$1.call(Install.java:44)

at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)

… 3 more

When I opened Gradle distribution zip file, that wrapper has downloaded, in a text editor, I got following:

301 Moved Permanently

Moved Permanently

The document has moved here.


Apache/2.2.3 (CentOS) Server at services.gradle.org Port 80

It seems host has changed for distribution archives, permanent redirect was configured for old location, but wrapper doesn’t seem to follow redirects.

Same issue occurred when I installed Gradle wrapper 1.10 and 1.11, using first matching Gradle version URL, and then 1.6 URL, failing in each and every case.

Only when changing wrapper configuration to use distributionUrl=https://downloads.gradle.org/distributions/gradle-1.6-bin.zip it started working again.

Please consider rising JIRA ticket for Gradle wrapper for this.

Same issue here, with gradle wrapper 1.9… It worked in the morning, but broke like 2 hours ago.

Same issue with 1.11

same for 1.10

[root@ci-cent5-001 ~]# curl https://services.gradle.org/distributions/gradle-1.9-bin.zip 301 Moved Permanently

Moved Permanently

The document has moved here.


Apache/2.2.3 (CentOS) Server at services.gradle.org Port 443

[root@ci-cent5-001 ~]# wget http://downloads.gradle.org/distributions/gradle-1.9-bin.zip --2014-04-10 11:00:42-- http://downloads.gradle.org/distributions/gradle-1.9-bin.zip Resolving downloads.gradle.org… 54.230.0.69, 54.230.0.91, 54.230.2.217, … Connecting to downloads.gradle.org|54.230.0.69|:80… connected. HTTP request sent, awaiting response… 200 OK Length: 40055092 (38M) [application/zip] Saving to: ‘gradle-1.9-bin.zip.1’

100%[===========================================================================================================================================================>] 40,055,092 9.11M/s

in 4.1s

2014-04-10 11:00:46 (9.36 MB/s) - ‘gradle-1.9-bin.zip.1’ saved [40055092/40055092]

Workaround:

------------- gradle-wrapper.properties distributionUrl=http://downloads.gradle.org/distributions/gradle-1.9-bin.zip

instead: distributionUrl=http://services.gradle.org/distributions/gradle-1.9-bin.zip

It helps if you cache it as part of your artifactory repos: http://stackoverflow.com/questions/18384861/gradle-distributions-repository-in-artifactory-outdated

Gradleware is aware and working on this.

Should be back to normal.

The change was the we enabled https for wrapper downloads. For some reason that I don’t understand yet, some environments don’t deal with this well while others do.

FWIW, every wrapper request already involved redirects. It’s something more subtle.

If I could ask a favour…

Can you please try updating your ‘gradle/wrapper/gradle-wrapper.properties’ to use the ‘https://services.gradle.org’ URL.

You’ll have to do this:

  1. Kill all daemon processes 1. Remove the existing wrapper ‘rm -rf ~/.gradle/wrapper/dists/gradle-1.11-bin’ 1. Run ‘./gradlew’ build

If it doesn’t work, please post the Gradle output.

Thanks!

It works now: ’ d:\Workspaces\JavaDevelopment\1.5.3>gradlew clean compileJava --debug ’

Downloading https://services.gradle.org/distributions/gradle-1.10-bin.zip

Unzipping C:\Users\victorm.gradle\wrapper\dists\gradle-1.10-bin\4q0bb2i9nap9j7pt8jgurkeb68\gradle- 1.10-bin.zip to C:\Users\victorm.gradle\wrapper\dists\gradle-1.10-bin\4q0bb2i9nap9j7pt8jgurkeb68

11:30:47.610 [INFO] [org.gradle.BuildLogger] Starting Build

11:30:47.616 [DEBUG] [org.gradle.BuildLogger] Gradle user home: C:\Users\victorm.gradle

works for me using both

http://services.gradle.org and

https://…

IMO wrapper should be fixed to handle redirects, even if http services URLs started working again.

distributionUrl is generated by the wrapper task. If it should generate URL with https instead of http, I guess then also wrapper task needs to be fixed.

The wrapper does follow redirects. The URL that it has used since Gradle 1.1 results in a redirect.

java.net.URL is used to download the wrapper. On some JDKs this seems to have a problem with a redirect that switches protocols. That was the new bit yesterday.

Generated wrapper URLs will use https as of Gradle 1.12.

Services URL works with http and https for me now.