栏目分类:
子分类:
返回
终身学习网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
终身学习网 > IT > 软件开发 > 后端开发 > Java

aar发布到阿里云效 笔记

Java 更新时间:发布时间: 百科书网 趣学号
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("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
转载请注明:文章转载自 www.051e.com
本文地址:http://www.051e.com/it/273807.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 ©2023-2025 051e.com

ICP备案号:京ICP备12030808号