aar发布到阿里云效 笔记

本文介绍了如何通过两种Gradle插件——maven和maven-publish——将AAR文件上传到阿里云效。首先展示了使用maven插件的步骤,包括配置仓库URL、认证信息以及执行上传任务。接着,详细说明了maven-publish插件的用法,创建上传任务,设置发布信息,并执行publish任务。无论选择哪种方式,都需要配置正确的环境和认证信息。
摘要由CSDN通过智能技术生成

aar发布到阿里云效 笔记

1. 使用 maven插件上传aar

环境
Gradle版本:6.5
AGP 版本 :4.1.2
Android Studio Arctic Fox | 2020.3.1 Patch 2
Gradle脚本语言:Groovy

官网的代码,不解释
//groovy
apply plugin: 'maven'

android {
	...
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: 'https://packages.aliyun.com/maven/repository/') {
                authentication(
                        userName: 'xxxxxxxxxxxxx',
                        password: 'e[xxxxxxxxxxxxx'
                )
            }
            snapshotRepository(url: 'https://packages.aliyun.com/maven/repository/') {
                authentication(
                        userName: 'xxxxxxxxxxxxx',
                        password: 'e[xxxxxxxxxxxxx'
                )
            }
            pom.version = android.defaultConfig.versionName
            pom.artifactId = 'final'
            pom.groupId = 'com.example'
        }
    }
}
执行 uploadArchives,发布到阿里云效
//mac 
./gradlew :moduleName:uploadArchives
//windows 
gradlew :moduleName:uploadArchives

2. 使用 maven-publish插件上传aar

环境
Gradle版本:7.0.2
AGP 版本 :7.0.2
Android Studio Arctic Fox | 2020.3.1 Patch 2
Gradle脚本语言:kotlin

编写上传Task
//kotlin
plugins {
	//maven插件在6.8之后移除了
	//使用新的maven-publish插件
	//添加maven-publish插件
    id("maven-publish")
}

android {
	...
}

afterEvaluate {
    publishing {
        publications {
            //随便取,这是task的名字
            //可以create多个
            //比如 release 一个 debug一个,配置不同的信息
            create<MavenPublication>("snapshot") {
                //release 或者debug
                from(components.getByName("release"))
                //不解释
                groupId = "com.example.MyLibrary"
                //不解释
                artifactId = "final"
                //不解释
                version = "1.0"
                repositories {
                    maven {
                        //repository的名字,随便取
                        name = "myRepo"
                        //阿里云效的地址,仓库地址
                        url = uri("https://packages.aliyun.com/maven/repository/")
                        credentials {
                            //阿里云效的用户名
                            username = "xxxxxxxx"
                            //阿里云效的密码
                            password = "e[xxxxxxxx"
                        }
                    }
                }
            }
        }
    }
}
执行 publish,发布到阿里云效
//mac 
./gradlew :moduleName:publish
//windows 
gradlew :moduleName:publish
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值