緣起
之前看到使用用了github來做maven倉庫的教程,但國內github的速度不給力,個人偏向於使用碼雲gitee平臺,便使用碼雲搭建了一個maven倉庫,記錄了下搭建過程。
簡單來說,共有三步:
- deploy到本地目錄
- 把本地目錄提交到碼雲上
- 配置git地址爲倉庫地址
配置local file maven倉庫
deploy到本地
maven可以通過http, ftp, ssh等deploy到遠程服務器,也可以deploy到本地文件系統裏。
例如把項目deploy到C:/gitFiles/maven/repository/目錄下:
<distributionManagement>
<repository> <id>xwintop-maven</id> <url>file:C:/gitFiles/maven/repository/</url> </repository> </distributionManagement>
- 1
- 2
- 3
- 4
- 5
- 6
通過命令行則是:
mvn deploy -DaltDeploymentRepository=xwintop-maven::default::file:C:gitFiles/maven/repository/
- 1
推薦使用命令行來deploy,避免在項目裏顯式配置。
https://maven.apache.org/plugins/maven-deploy-plugin/
https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html
把本地倉庫提交到github上
上面把項目deploy到本地目錄C:/gitFiles/maven/repository/
裏,下面把這個目錄提交到gitee上。
在碼雲上新建一個項目maven,然後把C:/gitFiles/maven/
下的文件都提交到碼雲上。
cd C:gitFiles/maven
git init
git add repository/*
git commit -m 'deploy xxx'
git remote add origin [email protected]:xwintop/maven.git
git push origin master
- 1
- 2
- 3
- 4
- 5
- 6
最終效果可以參考我的個人倉庫:
https://gitee.com/xwintop/maven
gitee碼雲 maven倉庫的使用
因爲碼雲使用了gitee.com/${user_account}/${project_name}/raw/${branch}這個域名用於raw文件下載。所以使用這個maven倉庫,只要在pom.xml裏增加:
<repositories>
<repository> <id>xwintop-maven</id> <url>https://gitee.com/xwintop/maven/raw/master/repository</url> </repository> </repositories>
- 1
- 2
- 3
- 4
- 5
- 6
目前國內使用碼雲平臺託管的項目比較多,速度快,功能強大,推薦大家使用,謝謝。