本文基于sonatypeUploader 2.6
版本
- 插件的使用實例:https://github.com/jeadyx/SonatypeUploaderSample
發布步驟
-
提前準備好
sonatype
賬號和signing
配置
注:如果沒有,請參考1.0博文的生成步驟: https://jeady.blog.csdn.net/article/details/139945691 -
導入插件
plugins { id("org.jetbrains.dokka") version "1.9.20" // kotlin代碼生成javadoc的插件,不需要的話可以注釋掉id("io.github.jeadyx.sonatype-uploader") version "2.6"
}
- 配置插件信息
// 以`io.github.jeady5:$moduleName:1.0`為例
group = "io.github.jeady5"
version = "1.0"
sonatypeUploader {tokenName = "tokenUser" // 在sonatype中`View Account`頁面進行生成: https://central.sonatype.com/accounttokenPasswd = "tokenUserPasswd"
// signing = Action<UploaderSigning> { // 如果已配置signing插件,此代碼可以忽略;如果是gradle小白或測試用可以在這里填寫簽名信息進行測試,為了安全推薦使用`gradle.properties`文件
// keyId="F56168C8"
// keyPasswd="123123"
// secretKeyPath="E:\\gpg\\jeady_0xF56168C8_SECRET.gpg"
// }pom = Action<MavenPom>{ // 配置pom信息,必須項; 改成你自己的信息即可,不知道的網址可以填自己的倉庫地址。name = "My Library"description = "A concise description of my library greennbg"url = "http://www.example.com/library"licenses {license {name = "The Apache License, Version 2.0"url = "http://www.apache.org/licenses/LICENSE-2.0.txt"}}developers {developer {id = "jeady"name = "jeady"email = "jeady@example.com"}}scm {connection = "scm:git:git://example.com/my-library.git"developerConnection = "scm:git:ssh://example.com/my-library.git"url = "http://example.com/my-library/"}}
}
sync
項目gradle publishToSonatype
任務說明
-
1.createDeploymentDir
在本地生成要上傳的工件目錄,位置默認在模塊的build\sonayUploader
目錄里面 -
1.uploadDeploymentDir
上傳剛生成的目錄到sonatype 中心倉庫 -
3.publishDeployment
發布剛上傳的工件,不可取消 -
checkDeploymentStatus
檢查剛上傳組件的狀態
如果狀態為FAILED, 請根據提示信息進行更改,博主遇到了兩個 -
版本已存在: 更新版本解決
-
校驗簽名失敗: 查看本地簽名文件是否已上傳公共服務器
-
cleanLocalDeploymentDir
刪除本地生成的臨時工件目錄 -
deleteDeployment
刪除剛上傳的工件 -
publishToSonatype
一鍵發布
注意事項
- 記得將公鑰上傳到公共服務器
可用的公鑰管理服務器有:- https://keyserver.ubuntu.com
- https://keys.openpgp.org
- https://pgp.mit.edu
如果你使用的是GnuPG, 還可以在gui中進行操作,右鍵證書有個在服務器發布
:
后記
如果對你有幫助,請star倉庫:SonatypeUploader
使用中如果有什么問題,請提交issue
、評論、私信