使用com.novoda:bintray-release上传多模块到bintray jcenter

使用com.novoda:bintray-release上传多模块到bintray jcenter

[TOC]

注册bintray账号

  1. 官网注册账号 https://bintray.com,切记点击右边的For an Open Source Account。
  2. 创建一个名为maven的Maven类型的Repository。
  3. 在右上角,头像的下拉选项中,Edit Profile. 记录下自己的APP KEY和User Name。

注:不需要建package

使用

因为是多模块,我们统一配置

1. 在项目的build.gradle里(非模块)添加

buildscript {
    
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.novoda:bintray-release:0.8.1'
    }
}

classpath 里添加classpath ‘com.novoda:bintray-release:0.8.1

ext {
    userOrg = 'davy' #用户名
    repoName = "maven" #仓库名
    groupId = 'org.greenleaf.utils' #groupId
    desc = 'useful tool for android' #描述
    website = 'https://github.com/davyjoneswang/AndroidCommonUtils' #地址,填写真实可访问地址
    licences = ['Apache-2.0'] # 描述,填写licences
}

这些添加并修改为自己的配置。

  • desc 项目描述
  • website 项目网址,填写自己的github 项目网址,【验证时会用,填写能打开的项目网址】
  • licences 项目的licences。

《使用com.novoda:bintray-release上传多模块到bintray jcenter》 DX-20180611@2x.png

上图3个红框 分别为userOrg、repoName、uploadName。

2. 模块的的build.gradle配置

每个模块build.gradle都进行配置,例如:

apply plugin: 'com.novoda.bintray-release'

publish {
    artifactId = 'annotation'  # artifactId
    uploadName = 'AndroidCommonUtils' ## 展示名字
    publishVersion = '1.0.0' ## 版本
    userOrg = rootProject.userOrg
    groupId = rootProject.groupId
    desc = rootProject.description
    website = rootProject.website
    licences = rootProject.licences
}

artifactId不同。 版本号、版本号 我们自定义了。

3. 上传执行。

./gradlew clean generatePomFileForReleasePublication build bintrayUpload -PbintrayUser=*** -PbintrayKey=******** -PdryRun=false

使用自己的UserName和Key.

上传成功后,还不能直接使用,需要审核,通过后才能使用。

进入bintray,maven 仓库,项目。如果正常,你就可以看到你上传的文件,右侧有add to Jcenter按钮, 点击,填写信息,并勾选就可以等待审核了。

可参考实现,’https://github.com/davyjoneswang/AndroidCommonUtils

填坑

  1. 没有add to Jcenter按钮

请确认,是否按照上面的步骤注册的账号,Jcenter注册分为个人和企业。我们需要注册个人版。如果错了,请在右上角用户配置里,删除账号,重新注册。

  1. Could not create package HTTP/1.1 404 Not Found[message:Repo ‘maven’ was not found]

请创建maven仓库

  1. 提示 Please fix the following before submitting a JCenter inclusion request: Add a POM file to the latest version of your package.

这是因为插件没有创建pom文件,请确认是否是按照上面执行的 上传命令,直接使用插件官网的命令就会出现问题。 个人观察,如果你的工程包含Android模块,经常会这样。

参考:

    原文作者:DavyJones1
    原文地址: https://www.jianshu.com/p/b1ec1536f7c1
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞