本文使用'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
命令