gradle 上传maven库,遇到maven库地址未及时更新的问题

12 阅读1分钟

问题描述:

问题报错:

Could not publish configuration 'archives' > Failed to deploy artifacts: Could not transfer 
artifact com.dnake.medical:baseCoreModule:aar:1.0.60-alpha from/to remote 
(<http://192.168.14.234:8081/nexus/content/repositories/android-alpha/>):
Connection timed out: connect

在module的build.gradle文件中,使用gradl.properties配置maven库地址,在执行上传时,gradle.properties中已经是最新的maven地址,但上传过程中,仍使用旧的maven地址,导致无法上传成功;问题文件如下:

uploadArchives.gradle 文件

repository(url: ALPHA_REPOSITORY_URL) {

    authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)

    pom.project {
        version publishAlphaVersion
        groupId publishGroup
        artifactId publishGroupId
        packaging publishType
        description publishDescription
    }

gradle.properties文件

ALPHA_REPOSITORY_URL=http://192.168.96.234:8081/nexus/content/repositories/android-alpha/

这里的ALPHA_REPOSITORY_URL已经是最新的地址;问题就出在这个ALPHA_REPOSITORY_URL变量上面,gradle将其缓存到了全局,所以上传的时候,使用的仍是旧的

解决办法

检查 C:\Users\你的用户名\.gradle\gradle.properties 这个文件,里面的ALPHA_REPOSITORY_URL变量仍为旧地址;以下是其示例:

XQXC_SNAPSHOT_REPOSITORY_URL=http\://nexus.xingqiuxiuchang.cn\:12019/repository/maven-snapshots/
CENTRAL_RELEASE_REPOSITORY_URL=https\://s01.oss.sonatype.org/content/repositories/releases/
ALPHA_REPOSITORY_URL=http\://192.168.14.234\:8081/nexus/content/repositories/android-alpha/
org.gradle.parallel=true
signing.secretKeyRingFile=D\:/secring.gpg
android.injected.testOnly=false
XQXC_RELEASE_REPOSITORY_URL=http\://nexus.xingqiuxiuchang.cn\:12019/repository/maven-releases/
CENTRAL_NEXUS_USERNAME=13132777478
XQXC_NEXUS_USERNAME=admin
systemProp.https.proxyPort=80
NEXUS_USERNAME=admin
YUNXIAO_NEXUS_USERNAME=QMUkAJ
YUNXIAO_SNAPSHOT_REPOSITORY_URL=https\://packages.aliyun.com/maven/repository/2004615-snapshot-8I3s7X/
signing.keyId=954038C8
RELEASE_REPOSITORY_URL=http\://192.168.14.234\:8081/nexus/content/repositories/android/
systemProp.http.proxyPort=80