跳到主要内容

自建仓库




./gradlew photo:publish

photo 为子模块

publish 上传到仓库


settings kts

apply plugin: 'maven-publish'

tasks.register('comps') {
afterEvaluate {
println("Components: " + components*.name)
println("project : " + project.getName())
println("path: $buildDir/outputs/aar/${project.getName()}-release.aar")
}
}

publishing {
publications {
release(MavenPublication) {
afterEvaluate {
from components.release // 如果是Android库,发布release的AAR文件
//from components.java //jar
}
// afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) }
// artifact("$buildDir/outputs/aar/photo-release.aar")

groupId = 'top.arick'
artifactId = 'photo'
version = '1.0.4'

// 如果你有附加文件,比如sources或javadoc,可以用artifact函数添加
// artifact("build/outputs/aar/toastutils.aar") // 手动指定AAR文件路径
}

plugin(MavenPublication) {
groupId = 'top.arick'
artifactId = 'photo-lib'
version = '1.0.1'
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
}
}

repositories {
maven {
url = 'https://packages.aliyun.com/61e25f080e8bd55d5a5a8db1/maven/repo-vpmlp'
credentials {
username = '61e25f02ae805dbacc12a8de'
password = 'O2vTGFYUqDYV'
}
}
}

}

tasks.named("publishPluginPublicationToMavenRepository") {
dependsOn ":photo:bundleReleaseAar" // 添加bundleReleaseAar作为依赖
}


私有仓库

module kts
implementation("top.arick:photo:1.0.5")


project kts

buildscript {
repositories {
mavenCentral()
google()
maven("https://raw.githubusercontent.com/MetaCubeX/maven-backup/main/releases")
maven {
credentials {
username = "61e25f02ae805dbacc12a8de"
password = "O2vTGFYUqDYV" // 确保不要在代码库公开此密码
}
url = uri("https://packages.aliyun.com/61e25f080e8bd55d5a5a8db1/maven/repo-vpmlp")
}

}
}


subprojects {
repositories {
mavenCentral()
google()
maven("https://raw.githubusercontent.com/MetaCubeX/maven-backup/main/releases")
maven ("https://maven.aliyun.com/repository/public")
maven {
credentials {
username ="61e25f02ae805dbacc12a8de"
password = "O2vTGFYUqDYV"
}
url = uri("https://packages.aliyun.com/61e25f080e8bd55d5a5a8db1/maven/repo-vpmlp")
}
}

}