美文网首页
发布github多module包到jcenter并提供给其他项目

发布github多module包到jcenter并提供给其他项目

作者: summerlines | 来源:发表于2019-11-13 21:22 被阅读0次

    流程简要说明:

    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 到 已经create 好的 JCenter(your Repository)中即可

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

    完成之后即可在个人的JCenter 主页中看到相关库

    1. 发布到 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'
    

    相关文章

      网友评论

          本文标题:发布github多module包到jcenter并提供给其他项目

          本文链接:https://www.haomeiwen.com/subject/spbkictx.html