将项目发布到JCenter
2017-04-20 本文已影响67人
jzhu085
1. 创建项目,toastlibrary就是我们需要上传到JCenter的库

2. 引入上传插件
项目根目录的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用户账号
groupId = 'com.jzhu.io.toastlibrary' //library的唯一id,用包名即可
artifactId = 'toastlibrary' //仓库名,最后生成的可依赖:compile 'com.jzhu.io.toastlibrary:toastlibrary:1.0.0'
version = '1.0.0' //版本号
description = 'custom toast' //描述
website = "https://github.com/zhujian1989/freetoast" //github地址
}
3. 创建bintray账号
官网:https://bintray.com/
注册流程就不多说了
4. bintray中操作
a.点击 add New Repository 添加仓库

b.创建仓库,完成后如图


c.查看api key


4. 上传到JCenter,打开as的Terminal,执行如下命令,显示suc,恭喜你
./gradlew clean build bintrayUpload
-PbintrayUser=你的账号
-PbintrayKey=你的api key
-PdryRun=false
5. bintray中查看,并点击 Add to JCenter发布



6. 如何使用
发布到JCenter中,在未通过审核前
项目根目录的build.gradle
repositories {
jcenter()
maven{ url 'https://dl.bintray.com/zhujian19890805/maven'}
}
dependencies {
compile 'com.jzhu.io.toastlibrary:toastlibrary:1.0.0'
}
当项目通过审核过后会有通知,就可以愉快的使用了
