利用github搭建个人maven仓库

本文介绍了如何将本地Maven仓库部署到GitHub,包括将项目deploy到本地目录、提交到GitHub以及配置使用GitHub作为Maven仓库。重点强调了在使用GitHub作为Maven仓库时的目录查看、搜索方法以及maven-repository-metadata.xml文件在确保依赖更新中的作用。
摘要由CSDN通过智能技术生成

缘起

之前看到有开源项目用了github来做maven仓库,寻思自己也做一个。研究了下,记录下。

简单来说,共有三步:

  1. deploy到本地目录
  2. 把本地目录提交到gtihub上
  3. 配置github地址为仓库地址

配置local file maven仓库

deploy到本地

maven可以通过http, ftp, ssh等deploy到远程服务器,也可以deploy到本地文件系统里。

例如把项目deploy到/home/hengyunabc/code/maven-repo/repository/目录下:

1
2
3
4
5
6
< distributionManagement >
   < repository >
     < id >hengyunabc-mvn-repo</ id >
     < url >file:/home/hengyunabc/code/maven-repo/repository/</ url >
   </ repository >
</ distributionManagement >

通过命令行则是:

1
mvn deploy -DaltDeploymentRepository=hengyunabc-mvn-repo::default::file:/home/hengyunabc/code/maven-repo/repository/

推荐使用命令行来deploy,避免在项目里显式配置。

https://maven.apache.org/plugins/maven-deploy-plugin/

https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html

把本地仓库提交到github上

上面把项目deploy到本地目录home/hengyunabc/code/maven-repo/repository里,下面把这个目录提交到github上。

在Github上新建一个项目,然后把home/hengyunabc/code/maven-repo下的文件都提交到gtihub上。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值