注册Bintray账号
- 点击即直达 注册地址
建议直接关联 Github账号进行注册 & 登录

授权

注意事项:
网易邮箱和腾讯邮箱无法注册!!!!!
注册地址是 https://bintray.com/signup/oss
在Bintray上建立仓库

name写maven(因为上传的时候不指定的话默认仓库名是maven)
type选择maven
创建成功后就像上图我成功创建的maven仓库一样。

创建成功

创建仓库成功之后,则接着add package,add package按照以下截图及其文字说明配置
上传Library到自己创建的maven仓库
配置bintray-release插件
开源库上传自己的Library
https://github.com/novoda/bintray-release
根目录build添加bintray-release
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.novoda:bintray-release:0.5.0'//添加插件
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
// 配置2
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
}
// 配置3
allprojects {
tasks.withType(Javadoc) {
options{
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
需要上传Library的build添加
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'//添加bintray插件
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api 'com.yanyusong.y_divideritemdecoration:y_divideritemdecoration:2.0'
}
configurations.all { //循环一个个的依赖库
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested //获取当前循环到的依赖库
if (requested.group == 'com.android.support') {//如果这个依赖库群组的名字是com.android.support
if (!requested.name.startsWith("multidex")) { //且其名字不是以multidex开头的
details.useVersion '28.0.0'//这里指定需要统一的依赖版本
}
}
}
}
//添加配置
publish {
userOrg = 'zhang721688' //bintray注册的用户名
repoName = 'MyItemDecoration'//Binary上的刚才新建的仓库名(Repository)
groupId = 'com.zxn.divider' //compile引用时的第1部分groupId
artifactId = 'dividerlibrary' //compile引用时的第2部分项目名, // 依赖名compile 'x:y:z'中的项目名y
publishVersion = '1.0.0' //compile引用时的第3部分版本号,依赖名compile 'x:y:z'中的版本号z
desc = 'This is a library for recyclerview item'
website = 'https://github.com/zhang721688/MyItemDecoration'// VCS地址,即填写项目上传的Github地址
}
// 特别注意:保持你的library module的名字同artifactId一样
// 1. 背景
// 在Bintray上你的项目的maven-metadata.xml文件的路径=gruopId+"/"+module名称
// 如你的groupId=scut.carson_ho,artifactId是CircileView,但module名称是circlelibrary
// 此时,项目文件在scut.carson_ho.CircileView目录下的,但maven-metadata.xml文件却是在scut.carson_ho.circlelibrary目录下的。
// 2. 冲突:若你有多个项目groupId一样 & artifactId不一样,但module名称都是library的话,maven-metadata.xml文件的地址可能会一样,即都是:gruopId+"/"+module名称,那么就可能产生冲突
// 3. 解决方案:保持module名称和artifactId一致
上传项目到JCenter中
在AndroidStudio的 Terminal
输入以下命令
// 每行命令均用空格隔开,此处是为了展示才会分行
<-- Windows版本 -->
gradlew.bat clean build bintrayUpload
-PbintrayUser=carson-ho // Binary用户名
-PbintrayKey=************* // Binary上的API key,具体获取见下说明
-PdryRun=false
<-- Mac版本 -->
./gradlew clean build bintrayUpload
-PbintrayUser=carson-ho
-PbintrayKey=*****************************
-PdryRun=false
- 注:获取API Key(需回到
Jcenter
网站)

API Key

本机命令:
gradlew.bat clean build bintrayUpload -PbintrayUser=zhang721688 -PbintrayKey=xxx -PdryRun=false
最有有效的命令
gradlew clean build bintrayUpload -PbintrayUser=zhang721688 -PbintrayKey=838701a79a44c97075eda1019ee0a26428f4003e -PdryRun=false
代码上传中

添加到JCenter

到此就结束了,不过目前还是不能直接引用的,你需要等待bintray的工作人员审核,审核通过会给你发送站内Message,并且Add to Jcenter那个按钮就会消失了,此外你还可以根据你上传的groupId,访问该网站https://jcenter.bintray.com/你的groupId例如https://dl.bintray.com/zhang721688/MyItemDecoration/
最后耐心等待Bintray审核通过。
常见错误
:webviewlibrary:bintrayUpload: Could not find publication: release.
参考文献:
https://www.jianshu.com/p/b1fcbbab0bbd
https://www.jianshu.com/p/6a6eca8c24c4
网友评论