使用github作为maven仓库的方法

一、使用github作为maven仓库的优势

  • 1、不用申请公共仓库账号
  • 2、和github代码版本保持一致

二、方法

  • 1、使用jitpack.io
    • 关于jitpack.io的使用文章网上有很多,在这里不做过多介绍了
  • 2、新建github仓库作为maven仓库
    • 1、这种方法实际上利用github的raw服务把git仓库当作http下载服务使用,例如我的仓库:https://github.com/MasonLiuChn/MasonMavenRepository
    • 2、步骤1,将你JavaLibrary工程或者AndroidLibrary工程打包发布到本地Maven仓库
    • 3、步骤2,将发布好本地Maven仓库push到git远程仓库
    • 4、步骤3,使用时配置github raw服务的地址,例如我的一个Library:https://github.com/MasonLiuChn/Dagger2Plus
    • 5、上述步骤我写了一个gradle 插件方便大家将library发布到一个git仓库里。

三、GMaven插件

将你的Android Library Module或者Java Library Module 打包发布到github上,作为Maven仓库可以使用maven、gradle引用。

  • 1、在build.gradle进行如下配置
buildscript {
    repositories {
        ...
        maven { url "https://github.com/MasonLiuChn/MasonMavenRepository/raw/maven/releases" }
    }
    dependencies {
        ...
        classpath 'com.masonliu:gmaven:1.0.8'
    }
}
apply plugin: 'maven'
apply plugin: 'gmaven'
gmavenGitRepo {
    organization = 'your organization name like MasonLiuChn'
    repository = 'your repository name like MasonMavenRepository'
    branch = 'master'
    type = 'releases'
}

gmavenLibrary {
    group = 'com.masonliu'
    artifactId = 'test_plugin'
    version = '1.4.5'
    packaging = 'aar'
    description = "description"
}
  • 2、执行 uploadToGit gradle task 例如 “gradle uploadToGit”

  • 3、library打包上传后使用方法如下面例子:

repositories {
    maven { url "https://github.com/MasonLiuChn/MasonMavenRepository/raw/maven/releases" }
}

dependencies {
    compile 'net.masonliu:dagger2plus:1.0.0'
    apt 'net.masonliu:dagger2plus-compiler:1.0.0'
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值