github~通過packages功能實(shí)現(xiàn)maven倉(cāng)庫(kù)托管
github在被大微軟收購(gòu)之后,推出了很多非常不錯(cuò)的功能,這一次把很多倉(cāng)庫(kù)管理合并到一起了,包括了nuget,npm,maven,docker等等,今天我們把java代碼推到github的maven倉(cāng)庫(kù)吧!
申請(qǐng)一個(gè)github token

建立一個(gè)倉(cāng)庫(kù),起名為maven_repo

配置你的.m2/settings.xml文件
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/bfyxzls/maven_repo</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>bfyxzls@sina.com</username>
<password>剛才生成的token在這里就不泄漏了</password>
</server>
</servers>
</settings>
在項(xiàng)目pom.xml里指定它,發(fā)布者和使用者都需要配置
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/bfyxzls/maven_repo</url>
</repository>
</distributionManagement>
發(fā)布你的包到github packages
mvn deploy
你最終發(fā)布的包在這里

參考文章
- https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry
- https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
- https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
浙公網(wǎng)安備 33010602011771號(hào)