使用Maven Publish Plugin插件。(官方支持)
plugins {
id 'com.Android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'maven-publish'
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId = 'GROUP ID' //publish
artifactId = '产口ID'
version = '1.0.3'
from components.release
}
}
repositories {
maven {
url = "MAVEN 仓库地址"
allowInsecureProtocol(true)
credentials {
username = '账号名'
password = '密码'
}
}
}
}
}
请使用Run 将本地库模块运行无误后再进行打包。
maven publish
1.在rootProject的buildScript中配置仓库地址
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url '配置的仓库地址' }
}
}
2.在module中的build.gradle中配置:
api "androidx.core:core-ktx:1.6.0" //配置为 api "GroupdId: 产品ID:版本号"