IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 移动开发 -> Kudu-1.16编译中下载Gradle依赖失败的解决办法 -> 正文阅读

[移动开发]Kudu-1.16编译中下载Gradle依赖失败的解决办法

Kudu-1.16编译中下载Gradle依赖失败的解决办法

最近在国内的机器上编译Impala的native-toolchain,没法挂代理,发现编译kudu-1.16时失败了:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildSrc:compileGroovy'.
> Could not resolve all files for configuration ':buildSrc:compileClasspath'.
   > Could not resolve com.github.ben-manes:gradle-versions-plugin:0.41.0.
     Required by:
         project :buildSrc
      > Could not resolve com.github.ben-manes:gradle-versions-plugin:0.41.0.
         > Could not get resource 'https://clojars.org/repo/com/github/ben-manes/gradle-versions-plugin/0.41.0/gradle-versions-plugin-0.41.0.pom'.
            > Could not GET 'https://repo.clojars.org/com/github/ben-manes/gradle-versions-plugin/0.41.0/gradle-versions-plugin-0.41.0.pom'.
               > Read timed out
   > Could not resolve gradle.plugin.org.barfuin.gradle.jacocolog:gradle-jacoco-log:1.2.4.
     Required by:
         project :buildSrc
      > Could not resolve gradle.plugin.org.barfuin.gradle.jacocolog:gradle-jacoco-log:1.2.4.
         > Could not get resource 'https://clojars.org/repo/gradle/plugin/org/barfuin/gradle/jacocolog/gradle-jacoco-log/1.2.4/gradle-jacoco-log-1.2.4.pom'.
            > Could not GET 'https://repo.clojars.org/gradle/plugin/org/barfuin/gradle/jacocolog/gradle-jacoco-log/1.2.4/gradle-jacoco-log-1.2.4.pom'.
               > Read timed out
   > Could not resolve gradle.plugin.com.google.gradle:osdetector-gradle-plugin:1.7.0.
     Required by:
         project :buildSrc
      > Could not resolve gradle.plugin.com.google.gradle:osdetector-gradle-plugin:1.7.0.
         > Could not get resource 'https://clojars.org/repo/gradle/plugin/com/google/gradle/osdetector-gradle-plugin/1.7.0/osdetector-gradle-plugin-1.7.0.pom'.
            > Could not GET 'https://repo.clojars.org/gradle/plugin/com/google/gradle/osdetector-gradle-plugin/1.7.0/osdetector-gradle-plugin-1.7.0.pom'.
               > Read timed out
   > Could not resolve gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.0.
     Required by:
         project :buildSrc
      > Could not resolve gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.0.
         > Could not get resource 'https://clojars.org/repo/gradle/plugin/com/github/spotbugs/snom/spotbugs-gradle-plugin/4.7.0/spotbugs-gradle-plugin-4.7.0.pom'.
            > Could not GET 'https://repo.clojars.org/gradle/plugin/com/github/spotbugs/snom/spotbugs-gradle-plugin/4.7.0/spotbugs-gradle-plugin-4.7.0.pom'.
               > Read timed out
   > Could not resolve io.spring.gradle:propdeps-plugin:0.0.10.RELEASE.
     Required by:
         project :buildSrc
      > Could not resolve io.spring.gradle:propdeps-plugin:0.0.10.RELEASE.
         > Could not get resource 'https://clojars.org/repo/io/spring/gradle/propdeps-plugin/0.0.10.RELEASE/propdeps-plugin-0.0.10.RELEASE.pom'.
            > Could not GET 'https://repo.clojars.org/io/spring/gradle/propdeps-plugin/0.0.10.RELEASE/propdeps-plugin-0.0.10.RELEASE.pom'.
               > Connect to repo.clojars.org:443 [repo.clojars.org/146.75.113.128] failed: connect timed out
   > Could not resolve net.ltgt.gradle:gradle-errorprone-plugin:2.0.2.
     Required by:
         project :buildSrc
      > Could not resolve net.ltgt.gradle:gradle-errorprone-plugin:2.0.2.
         > Could not get resource 'https://clojars.org/repo/net/ltgt/gradle/gradle-errorprone-plugin/2.0.2/gradle-errorprone-plugin-2.0.2.pom'.
            > Could not GET 'https://repo.clojars.org/net/ltgt/gradle/gradle-errorprone-plugin/2.0.2/gradle-errorprone-plugin-2.0.2.pom'.
               > Read timed out
   > Could not resolve me.champeau.gradle:jmh-gradle-plugin:0.5.3.
     Required by:
         project :buildSrc
      > Could not resolve me.champeau.gradle:jmh-gradle-plugin:0.5.3.
         > Could not get resource 'https://clojars.org/repo/me/champeau/gradle/jmh-gradle-plugin/0.5.3/jmh-gradle-plugin-0.5.3.pom'.
            > Could not GET 'https://repo.clojars.org/me/champeau/gradle/jmh-gradle-plugin/0.5.3/jmh-gradle-plugin-0.5.3.pom'.
               > Read timed out
   > Could not resolve com.google.gradle:osdetector-gradle-plugin:1.7.0.
     Required by:
         project :buildSrc > com.google.protobuf:protobuf-gradle-plugin:0.8.18
      > Could not resolve com.google.gradle:osdetector-gradle-plugin:1.7.0.
         > Could not get resource 'https://repo.maven.apache.org/maven2/com/google/gradle/osdetector-gradle-plugin/1.7.0/osdetector-gradle-plugin-1.7.0.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/com/google/gradle/osdetector-gradle-plugin/1.7.0/osdetector-gradle-plugin-1.7.0.pom'.
               > Read timed out
   > Could not resolve commons-lang:commons-lang:2.6.
     Required by:
         project :buildSrc > com.google.protobuf:protobuf-gradle-plugin:0.8.18
      > Could not resolve commons-lang:commons-lang:2.6.
         > Could not get resource 'https://repo.maven.apache.org/maven2/commons-lang/commons-lang/2.6/commons-lang-2.6.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/commons-lang/commons-lang/2.6/commons-lang-2.6.pom'.
               > Read timed out
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6m 7s
CMakeFiles/init_gradle.dir/build.make:79: recipe for target '../java/gradle/wrapper/gradle-wrapper.jar' failed
make[2]: *** [../java/gradle/wrapper/gradle-wrapper.jar] Error 1
make[2]: *** Deleting file '../java/gradle/wrapper/gradle-wrapper.jar'
CMakeFiles/Makefile2:1050: recipe for target 'CMakeFiles/init_gradle.dir/all' failed
make[1]: *** [CMakeFiles/init_gradle.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
make: *** [all] Error 2

于是参考这篇文章配了 ~/.gradle/init.gradle,使用阿里的源。
除了文章里提的,还要加上gradle-plugin和spring-plugin的URL:

allprojects{
  repositories {
    def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public'
    def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/public'
    def ALIYUN_GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
    def ALIYUN_GRADLE_PLUGIN_URL = 'https://maven.aliyun.com/repository/gradle-plugin'
    def ALIYUN_SPRING_PLUGIN_URL = 'https://maven.aliyun.com/repository/spring-plugin'
    all { ArtifactRepository repo ->
      if(repo instanceof MavenArtifactRepository){
        def url = repo.url.toString()
        if (url.startsWith('https://repo1.maven.org/maven2/')) {
          project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
          remove repo
        }
        if (url.startsWith('https://jcenter.bintray.com/')) {
          project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
          remove repo
        }
        if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
          project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GOOGLE_URL."
          remove repo
        }
        if (url.startsWith('https://plugins.gradle.org/m2/')) {
          project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL."
          remove repo
        }
        if (url.startsWith('https://plugins.gradle.org/m2/')) {
          project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL."
          remove repo
        }
        if (url.startsWith('https://repo.clojars.org/gradle/plugin')) {
          project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL."
          remove repo
        }
        if (url.startsWith('https://clojars.org/repo/gradle/plugin')) {
          project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL."
          remove repo
        }
        if (url.startsWith('https://clojars.org/repo/io/spring')) {
          project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_SPRING_PLUGIN_URL."
          remove repo
        }
        if (url.startsWith('https://repo.spring.io/plugins-release')) {
          project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_SPRING_PLUGIN_URL."
          remove repo
        }
      }
    }
    maven { url ALIYUN_REPOSITORY_URL }
    maven { url ALIYUN_JCENTER_URL }
    maven { url ALIYUN_GOOGLE_URL }
    maven { url ALIYUN_GRADLE_PLUGIN_URL }
    maven { url ALIYUN_SPRING_PLUGIN_URL }
  }
}

重新编译会发现错误少了很多,但还有一个URL没被替换:

FAILURE: Build failed with an exception.                        
                                                                                              
* What went wrong:                                                                  
Execution failed for task ':buildSrc:compileGroovy'.                                       
> Could not resolve all files for configuration ':buildSrc:compileClasspath'.
   > Could not resolve gradle.plugin.com.google.gradle:osdetector-gradle-plugin:1.7.0.     
     Required by:                                                                          
         project :buildSrc                                                                     
      > Could not resolve gradle.plugin.com.google.gradle:osdetector-gradle-plugin:1.7.0.
         > Could not get resource 'https://clojars.org/repo/gradle/plugin/com/google/gradle/osdetector-gradle-plugin/1.7.0/osdetector-gradle-plugin-1.7.0.pom'.
            > Could not GET 'https://repo.clojars.org/gradle/plugin/com/google/gradle/osdetector-gradle-plugin/1.7.0/osdetector-gradle-plugin-1.7.0.pom'.
               > Connect to repo.clojars.org:443 [repo.clojars.org/151.101.109.128] failed: connect timed out

不知为何这个URL没被替换,尝试直接改 kudu-1.16.0/java/settings.gradle,开头加上如下内容:

pluginManagement {
    repositories {
        maven {
            url 'https://maven.aliyun.com/repository/gradle-plugin'
        }
        gradlePluginPortal()
    }
}

再编译时报了另一个错:

* What went wrong:
Execution failed for task ':buildSrc:compileGroovy'.
> Could not resolve all files for configuration ':buildSrc:compileClasspath'.
   > Could not download shadow-6.1.0.jar (com.github.jengelman.gradle.plugins:shadow:6.1.0)
      > Could not get resource 'https://jcenter.bintray.com/com/github/jengelman/gradle/plugins/shadow/6.1.0/shadow-6.1.0.jar'.
         > Could not GET 'https://jcenter.bintray.com/com/github/jengelman/gradle/plugins/shadow/6.1.0/shadow-6.1.0.jar'.
            > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/6.8.3/userguide/build
_environment.html#gradle_system_properties
               > Remote host terminated the handshake

然后神奇的事情发生了,我回滚了settings.gradle的改动,发现编译就通过了……
可能中间有些状态或cache之类的改变了,回头再细挖,这里先简单记录一下。

参考文献

“Gradle Repositories 换用阿里云镜像”
https://luo3.org.cn/posts/snippets/replace-gradle-repositories-with-aliyun-mirrors/

  移动开发 最新文章
Vue3装载axios和element-ui
android adb cmd
【xcode】Xcode常用快捷键与技巧
Android开发中的线程池使用
Java 和 Android 的 Base64
Android 测试文字编码格式
微信小程序支付
安卓权限记录
知乎之自动养号
【Android Jetpack】DataStore
上一篇文章      下一篇文章      查看所有文章
加:2022-09-13 11:27:25  更:2022-09-13 11:31:49 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/25 5:23:41-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码