使用的工具准备:git,android studio;
git的安装与androidstudio的安装方法我们不再这里说了
1.在github上面创建repository
一.首先在github上Create a new repository
二.同步github上的文件夹到本地,等下要上传文件上去
三.打包需要上传的模块
1.在需要打包的模块的bulid.gradle里面加入
apply plugin: 'maven'
android {
...
defaultConfig {
...
versionCode 1
versionName "1.0"
}
}
ext {
PUBLISH_GROUP_ID = 'com.xx'
PUBLISH_ARTIFACT_ID = 'loadingdialog'
PUBLISH_VERSION = android.defaultConfig.versionName
}
uploadArchives {
repositories.mavenDeployer {
def deployPath = file(getProperty('aar.deployPath'))
repository(url: "file://${deployPath.absolutePath}")
pom.project {
groupId project.PUBLISH_GROUP_ID
artifactId project.PUBLISH_ARTIFACT_ID
version project.PUBLISH_VERSION
}
}
}
2.在项目根目录的gradle.properties里面加入
aar.deployPath=D:\\gradlelib\\xxrepo
这里是上面需要的地址,这个是我从github上面同步下的文件夹,就是需要把打包的文件输出到这里,然后上传。
3.gradle输出arr
选中需要打包的模块,点击upload/uploadArchives就行了,然后等待文件输出上传到githup
我的地址:https://github.com/baoya/xxrepo
4.通过gradle引用
复制出当前界面的连接地址,比如
https://github.com/baoya/xxrepo
对其进行修改:
https://raw.githubusercontent.com/baoya/xxrepo/master
即 github.com ——> raw.githubusercontent.com
再在末尾追加/master
表示当前要选用的是master分支的内容
在项目根目录下
allprojects {
repositories {
jcenter()
mavenCentral()
...
maven {url "https://raw.githubusercontent.com/baoya/xxrepo/master"}
}
}
在需要用到的地方
compile 'com.xx:loadingdialog:1.0'