1.搭建nexus+maven私有服务器,此步略过
2.在模块build.gradle配置中加入
uploadArchives {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: MAVEN_URL) {
authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
}
pom.project {
version android.defaultConfig.versionName
artifactId ARTIFACT_ID
groupId GROUP_ID
packaging TYPE
description DESCRIPTION
}
}
}
}
3.配置gradle.properties以上使用的全局变量
org.gradle.daemon=true
#nexus maven配置
MAVEN_URL= http://nexus.xxxx.com/content/repositories
#对应maven的groupId值
GROUP=group
#登录nexus oss的用户名
NEXUS_USERNAME=admin
#登录nexus oss的密码
NEXUS_PASSWORD=admin123
# groupid
GROUP_ID=package name
#artifactId
ARTIFACT_ID=artifact id
# type
TYPE = aar
# description
DESCRIPTION = description
4.以上配置完成执行gradlew uploadArchives上传任务,上传成功即可
如果遇到gradle task失败,报:gradle could not find method mavendeployer,请更换jdk1.8.