使用Github制作仓库的方式

方式一:使用Jitpack

  1. 首先我们需要将自己的工程传到GitHub上面。


    image.png
  2. 然后我们需要在root build.gradle添加如下依赖:

classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' // Add this line
image.png
  1. 在我们需要上传的那个module的build.gradle里面添加如下依赖:
apply plugin: 'com.github.dcendents.android-maven'  
image.png
  1. 进行aar的打包
    直接在控制台运行 gradlew install
image.png

然后我们会发现在对应的module的build里面生成了对应的aar文件:

image.png
  1. 现在将我们的整个项目再次提交到github上面
git add .
git commit -m 'debug'
git push origin master
  1. 现在进入github网站为我们的项目创建新的release
image.png

点击这个release进入这个界面

image.png

现在来创建一个新的release


image.png

等待项目发布完成。

  1. 进入JitPack控制台[https://jitpack.io]
    image.png

    登录完成后这里会展示我们的全部项目
    image.png

    找到我们的目标项目:
    image.png

    点击get 然后按照下面的提示 将远程依赖加入到项目里面。
    image.png
至此成功上传了我们自己的库到jitpack里面了。

方式二:使用Maven

首先先将你的项目上传到GitHub上面。

  1. 在需要上传的那个module 的build.gradle添加如下:
apply plugin: 'maven'
uploadArchives {
    repositories.mavenDeployer {
        //maven 本地文件地址
        def mavenLib = file(getProperty('mavenPath'))
        repository(url: "file://${mavenLib.absolutePath}")
        pom.project {
            version android.defaultConfig.versionName
            groupId GROUDID
            artifactId ARTIFACTID
        }
    }
}
image.png
image.png

同步下,我们可以在task里面看到如下信息:


image.png
  1. 运行任务 uploadArchives


    image.png
  2. 将代码全部提交到github仓库里面


    image.png

至此maven已经搞好了

仓库的地址是:

https://raw.githubusercontent.com/{username}/{projeceName}/{branch}

在访问https://raw.githubusercontent.com域名的时候可能会出现访问失败的情况。解决办法是进入ip查询网站:https://site.ip138.com 查到这个域名对应的ip地址 然后把ip地址加入到host文件里面。

image.png

  1. 添加依赖:
allprojects {
    repositories {
        google()
        jcenter()
        maven{//添加以下配置
            url 'https://raw.githubusercontent.com/[账户]/[工程名]/['
        }
    }

2.添加依赖

    implementation 'com.ddstar:maveLib:1.0'

参考博客:https://www.jianshu.com/p/4311b6ff4ec1?from=timeline&isappinstalled=0

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容