參考android 開發通過JitPack發布Android Library
1、 在項目的build.gradle添加插件android-maven-gradle-plugin
不同的gradle版本對應不同的插件版本
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.2"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
2、配置library的build.gralde
apply plugin: 'com.android.library'
// JitPack Maven
apply plugin: 'com.github.dcendents.android-maven'
// 其中username需要替換為你在github上的用戶名
group = 'com.github.username'
3、在Terminal中執行gradlew install 方法
image.png
4、將項目提交到Github
5、打開項目的github主頁,創建一個Release或Tag
image.png
image.png
成功后如下圖
image.png
6、進入jitpack設置與github倉庫綁定
Jitpack地址
如果是公開的倉庫,直接將你倉庫的地址粘貼在這里,然后點擊lookup就行了
image.png
然后選擇對應的版本點 Get it ,如果Log 對應的是綠色,說明正確。
然后在需要使用的項目中引用即可
image.png
如果你的倉庫是私密的,你需要給與jitpack權限即可,看參考博客