前言(以下步驟全在windows下操作)
為了能像Gson那樣方便的引入到studio中
compile 'com.google.code.gson:gson:2.6.2'
我決定嘗試將demo發(fā)布到bintray上,因為它是jcenter和maven的倉庫,之所以想用bintray状您,是不想像JitPack.io那樣引入的時候要在repositories里多聲明一句話(雖然jitpack要簡單得多)
maven { url "https://jitpack.io"}
上網(wǎng)查了一下,使用插件的方式是最快最省事的王带,于是下面簡單介紹下我使用的過程互墓,以免自己忘記了
bintray_release
A helper for releasing from gradle up to bintray
This is a helper for releasing libraries to bintray. It is intended to help configuring stuff related to maven and bintray. At the moment it works with Android Library projects, plain Java and plain Groovy projects, but our focus is to mainly support Android projects.
新建maven倉庫
image
Name處好像只能是寫成“maven”
創(chuàng)建package
image
準備要上傳的module
image
project gradle設(shè)置
image
classpath 'com.novoda:bintray-release:0.4.0'
tasks.withType(Javadoc) {
options {
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api"
}
}
module gradle設(shè)置
image
apply plugin: 'com.novoda.bintray-release'
image
tasks.withType(Javadoc) {
options {
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api"
}
}
publish {
userOrg = 'urwateryiyi'//bintray用戶名
groupId = 'com.zoey'//迷惑1 jcener上的路徑
artifactId = 'testagain'//項目名
publishVersion = '1.0.0'//版本號
desc = 'this is a test'//項目描述
website = 'https://github.com/Urwateryi/testcompile'//項目網(wǎng)址剩失,建議github開源庫網(wǎng)址
}
查找key
image
上傳命令
image
//這里PbintrayUser是你的bintray用戶名桑嘶,key則是上面的key
gradlew clean build bintrayUpload -PbintrayUser=bintray用戶名 -PbintrayKey=key -PdryRun=false
上傳成功
image
image
刷新bintray炊汹,上傳無誤的話,左下角會出現(xiàn)3種引用方式逃顶,那就是將來可以直接引入到項目中的語句讨便。
這時候還不能用,需要點擊"Add to jCenter"口蝠,去審核
審核及審核通過
image
image
2-3個小時后器钟,審核通過了津坑,才能使用
寫在最后
其實還有個問題妙蔗,就是怎么更新項目
方法1:
build.gradle中更新版本號,重新bintrayUpload疆瑰,compile的時候使用新版本
方法3:
使用快照眉反,此方法暫時還未掌握