我们的Android版本在我们公司的CI版本代理上运行。这些服务器无法访问互联网,必须从Artifactory中的虚拟存储库中获取所有Maven依赖项。
我现在注意到,所有构建都比在我的PC上花了几分钟的时间,显然延迟归因于Gradle尝试访问JCenter:
build 01-Apr-2019 11:56:44 11:56:43.449 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Opening connection {s}->https://jcenter.bintray.com:443
build 01-Apr-2019 11:56:44 11:56:43.452 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connecting to jcenter.bintray.com/18.195.111.75:443
build 01-Apr-2019 11:56:44 11:56:43.452 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Connecting socket to jcenter.bintray.com/18.195.111.75:443 with timeout 30000
build 01-Apr-2019 11:56:44 11:56:43.453 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connect to jcenter.bintray.com/18.195.111.75:443 timed out. Connection will be retried using another IP address
build 01-Apr-2019 11:56:44 11:56:43.454 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connecting to jcenter.bintray.com/35.156.75.35:443
build 01-Apr-2019 11:56:44 11:56:43.454 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Connecting socket to jcenter.bintray.com/35.156.75.35:443 with timeout 30000
当然,这是行不通的,但是Gradle似乎会一遍又一遍地重试,直到最终放弃。由于所有依赖项在Artifactory中都可用,因此该构建仍然可以正常工作。
这是我们当前为Gradle配置存储库的方式:
repositories {
def artifactoryBaseUrl = "https://artifactory.somecompany.com"
maven {
url "${artifactoryBaseUrl}/libs-release-local"
}
maven {
url "${artifactoryBaseUrl}/google-maven"
}
maven {
url "${artifactoryBaseUrl}/fabric-maven"
}
maven {
url "${artifactoryBaseUrl}/maven-central"
}
maven {
url "${artifactoryBaseUrl}/gradle-plugins"
}
maven {
url "${artifactoryBaseUrl}/jitpack-maven"
}
}
如您所见,根本没有提到JCenter-Gradle如何确定它要访问它,有什么办法可以禁用它?
我在日志中的更上方看到了它,但不知道它来自哪里:
build 01-Apr-2019 11:40:23 11:40:22.351 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.ResolvedArtifactCaches] Creating new in-memory cache for repo 'BintrayJCenter' [1dd858de07b774d6be9d3e38c5646087].
答案 0 :(得分:1)
Gradle构建只有一个默认存储库:用于解决Gradle插件的Gradle插件门户,该门户仅可用于解决构建脚本classpath
依赖关系,而不能解决项目依赖关系。
如果您看到自己的构建试图访问JCenter,则很可能是导入的构建文件或插件。