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/
|