本文使用'com.novoda:bintray-release
做为上传插件,下面以我我的的utils library上传为例进行说明:java
<!--more-->android
网址:https://bintray.com/signup/ossgit
注:可经过Github、Google、Twitter受权bintray实现注册github
网址:https://bintray.com/profile/editweb
操做步骤:apache
注意:Name选项框的值maven
必须是小写。bash
#Sun May 21 20:41:27 CST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip //非此版本号可能会存在`Could not generate a proxy class for class com.android.build.gradle.tasks.BuildArtifactReportTask.`此类错误
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' //非此版本号可能会存在`Could not generate a proxy class for class com.android.build.gradle.tasks.BuildArtifactReportTask.`此类错误 // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.novoda:bintray-release:+' // 新增 } } allprojects { repositories { jcenter() } tasks.withType(Javadoc) { // 新增 options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('encoding', 'UTF-8') } } task clean(type: Delete) { delete rootProject.buildDir }
apply plugin: 'com.android.library' apply plugin: 'com.novoda.bintray-release' // 新增 android { ... lintOptions { // 新增 abortOnError false } } dependencies { ... } publish { // 新增 userOrg = 'fqxyi' // 注册bintray时的username groupId = 'com.fqxyi' // 项目包名 artifactId = 'utils' // 项目名 publishVersion = '1.0.0' // 发布版本号 desc = 'Summarize the tools or methods commonly used in routine development' // 项目描述,可选项 website = 'https://github.com/fengqingxiuyi/AndroidUtils' // 项目站点,可选项 }
... android { ... lintOptions { // 新增 abortOnError false } } ...
命令:网络
gradlew clean build bintrayUpload -PbintrayUser=username -PbintrayKey=API Key -PdryRun=false
命令解释:app
API Key
选项中获得,网址:https://bintray.com/username/...maven
注意:
操做步骤:
访问https://jcenter.bintray.com/g...网址,若是能看到如下四个文件即表示申请经过:
artifactId-publishVersion-javadoc.jar artifactId-publishVersion-sources.jar artifactId-publishVersion.aar artifactId-publishVersion.pom
注意:网址中的groupId,默认是项目包名,在其成为网址的一部分后,须要将.
符号改成/
符号,例如:https://jcenter.bintray.com/com/fqxyi/utils/utils/1.0.0/
问题:
* What went wrong: Execution failed for task ':androidutilslibrary:bintrayUpload'. > Could not create package 'fqxyi/maven/androidutilslibrary': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
解决:未建立仓库 或 仓库名写错,注意maven是小写
问题:Lint检查报错,致使Build & Upload失败
解决:
方式一:须要自行根据错误信息修正Error级别的问题,
方式二:为Library项目的build.gradle配置如下Lint选项实现,--该方式摘自网络,未验证:
android { ... lintOptions { abortOnError false // 即便有报错也不会中止打包 checkReleaseBuilds false // 打包Release版本的时候也不进行Lint检测 } ... }
问题:
* What went wrong: Execution failed for task ':utils:bintrayUpload'. > javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
* What went wrong: Execution failed for task ':utils:bintrayUpload'. > org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1:8888 refused
* What went wrong: Execution failed for task ':utils:bintrayUpload'. > org.apache.http.NoHttpResponseException: The target server failed to respond
解决:
步骤1:关闭代理软件,重启网络;
步骤2:关闭由上传操做自动开启的Java客户端(Mac上会出现,其余设备不清楚)
问题:
上传成功后jcenter项目首页不显示pom,点击add to jcenter弹出如下错误提示:
Please fix the following before submitting a JCenter inclusion request: - Add a POM file to the latest version of your package.
是因为编码问题致使javadoc生成失败致使。
解决:
步骤1:在Project的build.gradle中配置如下语句:
... allprojects { ... tasks.withType(Javadoc) { // 新增 options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('encoding', 'UTF-8') } } ...
步骤2:拆分上传命令:
一、在Terminal执行gradlew clean build
命令。
二、先右击执行generatePomFileForReleasePublication task,再右击执行publishReleasePublicationToMavenLocal task,具体操做看图:
四、在Terminal中执行gradlew bintrayUpload -PbintrayUser=username -PbintrayKey=API Key -PdryRun=false
命令