josiahcarlson / redis-in-action

Example code from the book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maven Central deprecated http access causing 501 when gradle tries to fetch dependencies

senjin-hajrulahovic opened this issue Β· comments

Hi πŸ‘‹

When I try to run any chapter I get:

% ./gradlew -Pchapter=1 run
:compileJava

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve redis.clients:jedis:2.1.0.
  Required by:
      :redis-in-action:1.1
   > Could not HEAD 'http://repo1.maven.org/maven2/redis/clients/jedis/2.1.0/jedis-2.1.0.pom'. Received status code 501 from server: HTTPS Required
> Could not resolve org.javatuples:javatuples:1.2.
  Required by:
      :redis-in-action:1.1
   > Could not HEAD 'http://repo1.maven.org/maven2/org/javatuples/javatuples/1.2/javatuples-1.2.pom'. Received status code 501 from server: HTTPS Required
> Could not resolve com.google.code.gson:gson:2.2.2.
  Required by:
      :redis-in-action:1.1
   > Could not HEAD 'http://repo1.maven.org/maven2/com/google/code/gson/gson/2.2.2/gson-2.2.2.pom'. Received status code 501 from server: HTTPS Required

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.454 secs

When I try to access one of the links from the error messages I get:

501 HTTPS Required. 
Use https://repo1.maven.org/maven2/
More information at https://links.sonatype.com/central/501-https-required

Turns out that Maven Central disabled http access on 15th of January 2020:
https://blog.sonatype.com/central-repository-moving-to-https

The solution is to upgrade gradle to a more recent verision. This is the oldest version of gradle which uses https by default:
https://docs.gradle.org/2.1/release-notes.html#use-of-https-for-mavencentral()-and-jcenter()-dependency-repositories

As an alternative we can add following line to build.gradle:

maven { url "https://repo.maven.apache.org/maven2" }

I will open a PR with the gradle update.