Android使用gradle生成maven库,上传githu并使用远程maven库

整个demo 项目github  https://github.com/lihonghao1017/andoridHotFix

maven地址https://github.com/lihonghao1017/HotFixAndroidMaven

1,创建一个Androidstudio 项目

     注意   apply plugin: 'com.android.library'  不能是application;  applicationId ‘报名’也注释掉  

    需要    apply plugin : 'maven'  

2,创建生成maven文件Task

uploadArchives{
    repositories.mavenDeployer {
        def mavenRepositoryPath = file(getProperty('aar.hotfix'))//aar.hotfix定义在gradle.properties,为生成maven目录
        repository(url: "file://${mavenRepositoryPath.absolutePath}")
        pom.project{
            groupId "com.lihh.hotfix"
            artifactId "hotfix"
            version 1.1
        }
    }
}

gradle.property

Android使用gradle生成maven库,上传githu并使用远程maven库_第1张图片

3,生成maven文件  打开gradle任务管理器   app->upload->uploadArchives  点击uploadArchives  生成maven文件

Android使用gradle生成maven库,上传githu并使用远程maven库_第2张图片

4,在github上创建maven工程,clone到桌面mavenFirst文件夹, 将生成的maven 文件提交到github

5使用  我的maven地址为https://github.com/lihonghao1017/HotFixAndroidMaven  

     通过maven 访问 需要将github.com改为raw.githubusercontent.com;即https://raw.githubusercontent.com/lihonghao1017/HotFixAndroidMaven  

  

GitHub的raw.githubusercontent.com无法链接

修改Hosts临时解决GitHub的raw.githubusercontent.com无法链接

通过IPAddress.com首页,输入raw.githubusercontent.com查询到真实IP地址
199.232.28.133
C:\Windows\System32\drivers\etc
hosts文件
添加 以下内容并保存即可恢复
199.232.28.133  raw.githubusercontent.com

 

6. 使用项目加入依赖

repositories{
    jcenter()
    maven {
        url "https://raw.githubusercontent.com/lihonghao1017/HotFixAndroidMaven/master"
    }
}
dependencies {
    implementation 'com.lihh.hotfix:hotfix:1.0'
}

Android使用gradle生成maven库,上传githu并使用远程maven库_第3张图片

 

 

你可能感兴趣的:(Android,android,android,studio,maven)