發(fā)布github多module包到jcenter并提供給其他項目依賴使用

流程簡要說明:

  1. 【翻FQ墻】to JCenter https://bintray.com
    選擇免費的入口進行注冊:

    image.png

  2. 記住自己注冊的用戶名


    image.png
  3. 獲取API key [暫存,后面上傳gradle指令需要使用]


    image.png
  4. 進入jcener后Add new Repository


    image.png

需要注意的是添加的 Repository 的name maven和 as 中配置的

   repoName = "maven" // #倉庫名 一致
image.png
  1. 在需要上傳的庫根目錄下添加依賴[簡化jcenter的上傳依賴gradle 庫]
classpath 'com.novoda:bintray-release:0.x.x' [注意這里的版本和as的gradle有對應關系 ][https://github.com/novoda/bintray-release](https://bintray.com/)
  1. 在需要push的 module 對應的build.gradle 文件中添加配置:
apply plugin: 'com.novoda.bintray-release'

publish {
    artifactId = 'literouter'//  # artifactId
    uploadName = 'LiteRouter'// ## 展示名字
    publishVersion = '1.0.1'
    userOrg = rootProject.userOrg
    groupId = rootProject.groupId
    desc = rootProject.desc
    website = rootProject.website
    licences = rootProject.licences
}
  1. 上面是抽取了共性部分的使用,在根目錄下的gradle中ext:
ext {
    userOrg = 'your register name' // #用戶名
    repoName = "maven" // #倉庫名
    groupId = 'com.sparoj'//  #groupId :xxx
    desc = 'lite router for moudles' // #描述
    website = 'https://github.com/xxx/xxx.git'// #地址,填寫真實可訪問地址
    licences = ['Apache-2.0'] // # 描述,填寫licences
}
//  其他相同project 下的 module 上傳配置方式一致,注意替換對應的artifactId 和 uploadName、publishVersion 即可
  1. 使用前面view profile 得到的 key 通過如下gradle 指令在終端push 到 已經(jīng)create 好的 JCenter(your Repository)中即可

./gradlew clean build bintrayUpload -PbintrayUser=name -PbintrayKey=xxxkeyxxx -PdryRun=false

完成之后即可在個人的JCenter 主頁中看到相關庫

  1. 發(fā)布到 JCenter (add to JCenter )才可以在項目中依賴使用


    image.png
  2. 項目使用:

    compileOnly 'com.xxxxx:annotation:1.0.1'
    compileOnly 'com.xxx:xxxrouter:1.0.1'
    annotationProcessor 'com.xxx:compiler:1.0.1'
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容