github~通過packages功能實現maven倉庫托管
github在被大微軟收購之后,推(tui)出了(le)很(hen)多非(fei)常不錯(cuo)的功能(neng),這一次把很(hen)多倉(cang)庫(ku)管(guan)理合(he)并到一起了(le),包括(kuo)了(le)nuget,npm,maven,docker等等,今(jin)天我們把java代碼推(tui)到github的maven倉(cang)庫(ku)吧!
申請一個github token

建立一個倉庫,起名為maven_repo

配置你的.m2/settings.xml文件
<settings xmlns="//maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="//www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="//maven.apache.org/SETTINGS/1.0.0
//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>//repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>//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>
在項目pom.xml里指定它,發布者和使用者都需要配置
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>//maven.pkg.github.com/bfyxzls/maven_repo</url>
</repository>
</distributionManagement>
發布你的包到github packages
mvn deploy
你最終發布的包在這里
