如何發佈自己的 lib 庫到 jcenter

一 註冊一個 bintray 賬號

註冊的方法比較簡單,這裏就不說了。註冊網址 https://bintray.com/signup/oss

二 bintray 上傳教程

在根 build.gradle 添加以下代碼

buildscript {
  ...
  dependencies {
    classpath 'com.novoda:bintray-release:0.+' // 0.+ 表示最 0.xx新版
  }
}

然後在項目的 build.gradle 文件添加

publish {
  // 各個字段的含義見 https://github.com/novoda/bintray-release/wiki/Configuration-of-the-publish-closure
  Properties properties = new Properties()
  properties.load(project.rootProject.file('local.properties').newDataInputStream())
  def user = properties.getProperty('BINTRAY_USER')
  def key = properties.getProperty('BINTRAY_KEY')
  userOrg = user // 用戶名
  repoName = 'maven'
  dryRun = false // 重要
  groupId = _group
  artifactId = _artifactId
  publishVersion = _version
  desc = 'a dev tool lib for asm-plugin lib'
  website = _siteUrl
  bintrayUser = user // 用戶名
  bintrayKey = key  // api key 在個人信息裏面可以查詢到
}

上傳成功後,在 bintray 的 maven 詳細頁面有個 action ,點擊後有個 add to Jcenter 。 點擊後會推送到 jcenter 然後等待審覈通過。

另外一個小 tips ,就是如果訪問不了 https://bintray.com/ 的話,可以試試修改電腦的 DNS 爲 114.114.114.114 和 8.8.8.8 。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章