android studio自动上传aar到maven私库的配置

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.

    原文作者:飞飞
    原文地址: https://zhuanlan.zhihu.com/p/22475380
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞