配置项目
- 配置 项目的build.gradle文件,添加
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
, (版本号可通过在maven中央仓库查询,建议使用新版本) ,![添加插件配置](https://img-blog.csdnimg.cn/direct/6cebdecc2a6b4bfdb061d8a5172cd477.png#pic_center)
buildscript {
repositories {
...
}
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
- 在module的build.gradle文件添加配置
apply plugin: 'com.github.dcendents.android-maven'
, ![在module中添加插件依赖](https://img-blog.csdnimg.cn/direct/2a5b2307a5324891b3142573003346b0.png#pic_center)
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
- 同一个项目上支持多个module一起创建并上传
- 提交项目到github或gitee上,同时需要提交相对应的tag标签
如何发布
- 登录gitee,找到需要发布的项目地址,获取项目克隆地址,例如:https://gitee.com/rumeng/xxxxxx.git
- 打开
https://jitpack.io/
, 在输入框中输入项目克隆地址,点击 ‘look op’ 按钮,可查看当前项目提供的标签,点击 ‘get it’ ,等待编译,结果如图,log下显示红色的,表示编译失败,可点击图标进入查看失败详细日志,绿色的表示编译并发布成功, ,![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/01012ad213b14530bbdb018962350d45.png#pic_center)
引用项目
- 需要引用aar项目的gradle配置文件
allprojects.repositories
路径下添加 maven { url 'https://jitpack.io' }
为加载jitpack中的包提供下载地址, ![配置仓库地址](https://img-blog.csdnimg.cn/direct/c12ebaeb531440268bcf6fbfb479ee8e.png#pic_center)
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
- 引入的路径组成:github(或者gitee)的名称 + 项目名称 + tag(标签),
com.gitee.name:projectName:tag
, ‘com.gitee.rumeng:test-jit-pack:1.0.5’ - 同一个项目下有多个module的情况下的引用,
com.gitee.name.projectName:moduleName:tag
, ‘com.gitee.rumeng.test-jit-pack:test:1.0.5’