https://github.com/xbdcc/CUtils/blob/master/cutils/README.md
方式一:通過JitPack發(fā)布
-
首先新建一個Github倉庫嗅钻,然后可以看到這里有個releases,如下點擊
- 然后點擊這個
Draft a new release
按鈕,如下
- 填寫Tag版本號元暴,標題世囊,說明拙吉,也可以上傳附加文件盘榨,點擊
Publish releasse
按鈕即發(fā)布了硬霍,如下
- 這個時候在 https://jitpack.io/xbdcc/cutils 上便可以搜到自己發(fā)布的版本
方式二:發(fā)布到Sonatype
搭建自己的本地私服Sonatype Nexus
掏呼,配置好環(huán)境變量后執(zhí)行
nexus start
申請Sonatype賬號坏快,登錄后新建如下
按操作一步步來寫,然后上傳gradle代碼塊例子如下:
apply plugin: 'maven'
uploadArchives {
repositories.mavenDeployer {
// url為倉庫路徑憎夷,改為對應本地or其他路徑莽鸿,userName和password分別為Sonatype的用戶名和密碼
repository(url: "http://localhost:8081/repository/maven-releases/") {
authentication(userName: "caochang", password: "xbd")
}
snapshotRepository(url: "http://localhost:8081/repository/maven-snapshots/") {
authentication(userName: "caochang", password: "xbd")
}
// 唯一標識
pom.groupId = "com.carlos.cutils"
// 項目名稱
pom.artifactId = "cutils"
// 版本號,若為SNAPSHOT版本則需要在后面加-SNAPSHOT
pom.version = "0.1-SNAPSHOT"
}
}
方式三:發(fā)布到Bintray
- 首先在Bintray地址:https://bintray.com/signup/oss 注冊個人賬號
- 注冊完后創(chuàng)建maven倉庫拾给,創(chuàng)建對應的庫
- 使用bintray-release插件上傳
- 在project的build.gralde添加
classpath 'com.novoda:bintray-release:<latest-version>'
- 在library的build.gradle添加
配置如下:
apply plugin: 'com.novoda.bintray-release'
publish {
userOrg = 'xbdcc'
groupId = 'com.github.xbdcc'
artifactId = 'cutils'
publishVersion = '0.0.1'
desc = 'An android tool library.'
website = 'https://github.com/xbdcc/CUtils'
}
- 配置好后可以通過命令上傳
./gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME(替換為自己的bintray賬號) -PbintrayKey=BINTRAY_KEY(替換為自己的bintray key) -PdryRun=false
-
也可以通過點擊AS工作區(qū)右邊Gradle的bintrayUpload來上傳
引用方式
- project gradle下添加倉庫地址
// 方式一
maven { url 'https://jitpack.io' }
// 方式二
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'http://localhost:8081/repository/maven-releases/' }
// 方式三
maven { url 'https://dl.bintray.com/xbdcc/maven' }
- 在app的gradle下添加依賴
implementation 'com.carlos.cutils:cutils:0.0.25'