离线配置gradle[萌新篇]

原因:

前往Github中编译.jar文件.Gradle 在尝试下载其分发版本时遇到连接超时问题.

具体来说,错误发生在 Gradle 尝试从 https://services.gradle.org/distributions/gradle-8.3-bin.zip 下载文件时,连接超时.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
PS E:\meteor-client-master> .\gradlew build
Downloading https://services.gradle.org/distributions/gradle-8.3-bin.zip

Exception in thread "main" java.io.IOException: Downloading from https://services.gradle.org/distributions/gradle-8.3-bin.zip failed: timeout (10000ms)
at org.gradle.wrapper.Download.downloadInternal(Download.java:131)
at org.gradle.wrapper.Download.download(Download.java:89)
at org.gradle.wrapper.Install.forceFetch(Install.java:171)
at org.gradle.wrapper.Install.fetchDistribution(Install.java:104)
at org.gradle.wrapper.Install.access$400(Install.java:46)
at org.gradle.wrapper.Install$1.call(Install.java:81)
at org.gradle.wrapper.Install$1.call(Install.java:68)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
at org.gradle.wrapper.Install.createDist(Install.java:68)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:109)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:66)
Caused by: java.net.SocketTimeoutException: Connect timed out
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:633)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:304)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:178)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:532)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:637)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:380)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:193)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1242)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1128)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:179)
at java.base/sun.net.www.protocol.http.HttpURLConnection.followRedirect0(HttpURLConnection.java:2902)
at java.base/sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2811)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1927)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224)
at org.gradle.wrapper.Download.downloadInternal(Download.java:109)
... 10 more
PS E:\meteor-client-master>

下面是报错的主要部分的详细解析:

  • Caused by: java.net.SocketTimeoutException: Connect timed out: 这是连接超时的异常,意味着 Gradle 尝试建立连接时未能在指定的时间内完成连接.
  • 错误的发生可能是由于网络问题引起的.可能是由于网络不稳定、代理配置不正确、或者服务端的问题.

下面是一些方法:

  1. 检查网络连接: 确保你的网络连接正常,没有阻止 Gradle 下载的网络限制.尝试通过浏览器或其他方式访问 https://services.gradle.org/distributions/gradle-8.3-bin.zip,以确认是否能够正常访问
  2. 使用代理: 如果你在使用代理服务器,请确保 Gradle 配置了正确的代理设置.你可以在 Gradle 的配置文件中指定代理,具体的设置可能因你的网络环境而异
  3. 使用镜像源: 考虑使用国内的 Gradle 镜像源,这有助于加速下载.你可以在 Gradle 的配置文件中指定镜像源的地址
  4. 升级 Gradle 版本: 考虑升级 Gradle 到最新版本,以确保你使用的是最新的稳定版本,其中可能包含了修复一些网络相关的问题
  5. 手动下载: 如果以上方法都无效,你可以尝试手动下载 Gradle 分发版本并将其放置在 Gradle 默认下载目录中.然后运行你的项目,Gradle 将使用本地下载的分发版本.

手动下载/离线配置

我这里简单粗暴,直接查看了gradle\wrapper\gradle-wrapper.propertiesdistributionUrl配置的链接,然后去下载对应的gradle的宝贝进行离线配置.

浏览器直接下载services.gradle.org/distributions/gradle-8.3-bin.zip丢到E盘去然后直接引用[不需要解压]

注释的为原链接,distributionUrl=file:///E:/gradle-8.3-bin.zip为更换后的链接

jar文件就会构建到build/libs

meteor-client下载

彗星端0.5.4-1.20.1
彗星端0.5.5-1.20.2
彗星端[汉化]0.5.5-1.20.2
彗星端0.5.6-1.20.4