我要评分
获取效率
正确性
完整性
易理解

Failed to Download Gradle

Symptom

When executing compilation and installation commands, the message "Exception in thread "main" java.net.UnkownHostException:services.gradle.org..." is displayed. See the following figure.

Figure 1 Gradle download failure

Key Process and Cause Analysis

The possible cause is that a proxy is used to access the Internet, which results in download failure of the required package during compilation.

Conclusion and Solution

  1. Query the directory where Gradle fails to be downloaded.
    find / -name "gradle-4.10.2"

    The directory is located, as shown in the following figure.

  2. Delete the content from the directory.
    cd /root/.gradle/wrapper/dists/gradle-4.10.2-all/9fahxiiecdb76a5g3aw9oi8rv/
    rm -rf *
  3. Manually download the Gradle package and decompress it.
    wget https://services.gradle.org/distributions/gradle-4.10.2-all.zip --no-check-certificate
    unzip gradle-4.10.2-all.zip
  4. Perform the compilation and installation.
    1
    ./gradlew -c release-settings.gradle :java8:shadowJar
    

    If BUILD SUCCESSFUL is displayed, the compilation is successful.