1. 創(chuàng)建項(xiàng)目收捣,toastlibrary就是我們需要上傳到JCenter的庫(kù)
1.png
2. 引入上傳插件
項(xiàng)目根目錄的build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.novoda:bintray-release:0.4.0'
}
module中的build.gradle
apply plugin: 'maven'
apply plugin: 'com.novoda.bintray-release'
..............
..............
publish {
userOrg = 'zhujian19890805' //bintray用戶賬號(hào)
groupId = 'com.jzhu.io.toastlibrary' //library的唯一id,用包名即可
artifactId = 'toastlibrary' //倉(cāng)庫(kù)名絮缅,最后生成的可依賴:compile 'com.jzhu.io.toastlibrary:toastlibrary:1.0.0'
version = '1.0.0' //版本號(hào)
description = 'custom toast' //描述
website = "https://github.com/zhujian1989/freetoast" //github地址
}
3. 創(chuàng)建bintray賬號(hào)
官網(wǎng):https://bintray.com/
注冊(cè)流程就不多說了
4. bintray中操作
a.點(diǎn)擊 add New Repository 添加倉(cāng)庫(kù)
6.png
b.創(chuàng)建倉(cāng)庫(kù)操灿,完成后如圖
7.png
8.png
c.查看api key
10.png
12.png
4. 上傳到JCenter,打開as的Terminal,執(zhí)行如下命令懂从,顯示suc,恭喜你
./gradlew clean build bintrayUpload
-PbintrayUser=你的賬號(hào)
-PbintrayKey=你的api key
-PdryRun=false
5. bintray中查看蹲蒲,并點(diǎn)擊 Add to JCenter發(fā)布
3.png
13.png
![15.png](http://upload-images.jianshu.io/upload_images/2751425-f190d250ddb96856.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/800)
6. 如何使用
發(fā)布到JCenter中番甩,在未通過審核前
項(xiàng)目根目錄的build.gradle
repositories {
jcenter()
maven{ url 'https://dl.bintray.com/zhujian19890805/maven'}
}
dependencies {
compile 'com.jzhu.io.toastlibrary:toastlibrary:1.0.0'
}
當(dāng)項(xiàng)目通過審核過后會(huì)有通知,就可以愉快的使用了
![17.png](http://upload-images.jianshu.io/upload_images/2751425-58f2f7cb94bd0ee1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/800)