android studio Gradle7.0发布内容到Maven仓库
Gradle6.x及以下版本的使用apply plugin: 'maven'uploadArchives {repositories {mavenDeployer {repository(url: url//私有maven库地址) {authentication(userName//账号, password// 密码)}pom.version = version
·
Gradle6.x及以下版本的使用
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: url//私有maven库地址) {
authentication(userName//账号, password// 密码)
}
pom.version = version // 版本信息
pom.artifactId = artifactId // 项目信息
pom.groupId = groupId
pom.name = name
pom.packaging = packaging // 打包类型,例如:aar
}
}
}
配置完成后即可在Gradle Tasks视图中看到uploadArchives task,点击即会自动打包并上传到配置的maven仓库
对于repository的url配置有几种:
- 配置到当前路径的某个文件夹:repository(url: uri(’…/repository’))
- 配置到具体的路径:repository(url: uri(‘file://E:/repository’))
- 配置到服务器:repository(url: http://…)
Gradle7.0及以上版本的使用
apply plugin: 'maven-publish'
afterEvaluate {
publishing {
repositories {
// 本地仓库
maven {
name('modulelive')
url uri("../repo")
}
// 远程仓库
maven {
allowInsecureProtocol(true)
name('modulelive')
url = url//私有maven库地址
credentials {
username// 账号
password// 密码
}
}
}
publications {
debugType(MavenPublication) {
from components.debug
groupId "com.example.live"
artifactId "modulelive"
version "1.0.0"
}
releaseType(MavenPublication) {
from components.release
groupId "com.example.live"
artifactId "modulelive"
version "1.0.0"
}
}
}
}
Android官方介绍:maven-publish
Gradle官方介绍:maven-publish
更多推荐
已为社区贡献6条内容
所有评论(0)