发布aar到jcenter

准备工做

  1. 建立bintray帐号;
    1. https://bintray.com/, 选择以下图中,方框内"Sign Up Here":
      sign up
    2. 选择合适的方式,建立帐号:
      Create Account
  2. 新建仓库:
    1. Add New Repository
      bashboardgit

    2. Create Repository
      github

    Type选择"Maven",Name最好直接填"maven".
    这里是我建立的仓库:
    My Repoweb

  3. 建立 ApiKey.
    API KEYshell

走到这一步,帐号相关的工做已经完成了。bash

AAR的上传发布

在这里,上传aar使用的是bintray-release这个工具,这是我所知的最简单的一个工具。app

  1. 修改项目根目录下的build.gradle:在dependencies中添加以下代码
    groovy classpath 'com.novoda:bintray-release:0.8.1'
    其中,0.8.1是如今最新的版本,最新的版本号能够到bintray-release查看。maven

  2. 在上传的module下的build.gradle下添加:
    groovy apply plugin: 'com.novoda.bintray-release' publish { userOrg = 'novoda' groupId = 'com.novoda' artifactId = 'bintray-release' publishVersion = '0.6.1' desc = 'Oh hi, this is a nice description for a project, right?' website = 'https://github.com/novoda/bintray-release' }
    若是像我同样在准备工做中建立的仓库Name不为“maven”的话,须要在publish中添加一行:
    groovy repoName = 'common-util' // 这里填你本身仓库的Name
    不然,进行上传操做时会报以下错误:工具

    Could not create package 'diql/maven/common-util': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]gradle

  3. 上传:
    上传以前要保证本身的module已经把aar编译出来。
    在命令行中执行以下命令:
    shell ./gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false
    其中,BINTRAY_USERNAME为注册的用户名, BINTRAY_KEY为刚刚的API key.
    最后BUILD SUCCESSFUL,aar就上传成功了,能够到本身帐号的相关仓库中查看。
    common-utilui

    这个时候已经能够经过添加本身的仓库地址,即图中的地址到本身项目中:

    而后使用以下方式来引用本身的库了:

  4. 发布到jcenter
    aar上传成功后,能够经过右下角的"Add to JCenter"(以下图)将本身的库发布到jcenter

    通过审核后,帐号会接到相关通知,同时右下角会变成以下样式:

    这个时候,项目就正式的发布到jcenter中了。

相关文章
相关标签/搜索