1.设置gradle版本到8.0
gradle-wrapper.properties文件中设置:
distributionUrl=https\://mirrors.aliyun.com/macports/distfiles/gradle/gradle-8.0-bin.zip
2.设置项目根目录build.gradle
设置agp版本和maven插件版本(和gralde版本有对应关系)
dependencies {
classpath "com.android.tools.build:gradle:7.4.2"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
3.设置模块目录的build.gradle
如下
1 是上传本地jar包到maven的配置.
2是上传当前module生成的aar到maven 配置.
Groovy
apply plugin: 'maven-publish'
publishing {
//1.上传本地jar包到maven
publications {
mavenJava(MavenPublication) {
groupId = 'com.your.group'
artifactId = 'framework-bluetooth'
version = '1.0.0'
artifact file('libs/aa.jar')
}
}
//2.打开如下注释即可 上传当前module生成的aar到maven
// publications {
// release(MavenPublication) {
// groupId = 'com.android.demo' // 组织标识^^1^^2^^
// artifactId = 'uploadmavenp' // 模块名
// version = '20570725a' // 版本号
//
// // 自动关联Release AAR产物
// afterEvaluate {
// artifact(tasks.getByName("bundleReleaseAar"))
// }
// }
// }
repositories {
maven {
url "http://your-maven-server/repository/path"
credentials {
username 'your_username'
password 'your_password'
}
}
}
}
4.执行上传命令
/gradlew publish
或者双击gralde面板中publishing目录下的 publishAllPublicationsToMavenRepository
即可上传 模块目录下 libs/aa.jar文件到maven服务器
或者上传当前module编译的aar到maven服务器。