7.0以下的Android插件工程使用Maven上传时脚本如下所示。
plugins {id 'com.android.library'id 'kotlin-android'id 'maven'
}// 源代码一起打包
task androidSourcesJar(type: Jar) {archiveClassifier.set('sources')from android.sourceSets.main.java.sourceFiles
}uploadArchives {repositories.mavenDeployer {repository(url: "maven仓库地址") {authentication(userName: "maven用户名", password: "maven用户密码")}pom.project {name = "xxx"groupId "com.xxx.xxx" // 包名artifactId "xxx" // module的名字packaging "aar"version "1.0.0"// 版本号 }}
}
对于Gradle 7.0及以上版本,maven方式已经过时,我们需要maven-publish插件。以下是upload_release.gradle文件Gradle 7.0及以上版本的升级的写法,仅供参考。
apply plugin: