发布开源项目到 jitpack
---
theme: github
highlight: a11y-dark
---
# 发布项目到 jitpack
## *(Gradle7.x 的版本已不适用 android-maven 的方法发布)*
## 1.在要发布android module下的 build.grdle 添加,多个module就添加多个
```
plugins{
id 'maven-publish'
}
```
```
task sourceJar(type: Jar) {
classifier "sources"
from android.sourceSets.main.java.srcDirs
}
project.afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'com.github.xxxx'
artifactId = '项目名称'
version = '1.0.0'
}
}
}
}
```
### &如果是Java Library项目:
```
task sourceJar(type: Jar) {
classifier "sources"
from sourceSets.main.allJava
}
project.afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.java
groupId = 'com.github.xxx'
artifactId = 'xxx'
version = '1.0.0'
}
}
}
}
```
### a.在项目根目录。新建jitpack.yml,并指定jdk版本
```
jdk:
- openjdk11
```
### b.在项目的根目录添加
```
repositories {
maven { url "https://jitpack.io"}
}
```
## 2.push代码之后,添加tag ,并提交版本 1.0.0 ,-m 添加备注信息
```
git tag -a 1.0.0 -m tag-v1.0.0
```
## 3.提交到远程的方法
```
git push origin 1.0.0
```
## 4.查看tag的方法
```
git tag
```
## 5.删除tag的方法
```
git tag -d 1.0.0
git push origin :refs/tags/1.0.0
```
### 6.使用github账号,登录 [jitpack.io](http://jitpack.io) ,在左侧点击要发布的项目,然后再点击 Look up → **Get it**,等待Log加载完成。