there are three ways available to publish your packages
Github provide 500M free space for every account
First of all, publish your package: Add the following config to your package pom which to be published to github
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/{account}/maven-repository</url>
</repository>
</distributionManagement>
then mvn deploy
, check https://github.com/{account}/maven-repository/packages/ to find your package
So now, we can try to use the packge
add the token (applied from github) and repo address to our pom file
<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/{account}/maven-repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>{xxx}</username>
<password>TOKEN</password>
</server>
</servers>
Apply a token from github and give it user.email
permission
add the following config to maven config file:
<servers>
<server>
<id>github</id>
<username>{xxx}</username>
<password>TOKEN</password>
</server>
</servers>
then add this configs to pom file of the package to be publish to github
<properties>
<github.global.server>github</github.global.server>
</properties>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo
</altDeploymentRepository>
</configuration>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<configuration>
<message>Maven artifacts for ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<branch>refs/heads/main</branch>
<merge>true</merge>
<includes>
<include>**/*</include>
</includes>
<repositoryName>maven-repository</repositoryName>
<repositoryOwner>xxx</repositoryOwner>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
now just need mvn clean deploy
and we can use the package in this way:
<dependencies>
<dependency>
xxxxx
</dependency>
</dependencies>
<repositories>
<repository>
<id>github</id>
<url>https://raw.githubusercontent.com/trumandu/maven-repository/main/repository</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
https://blog.csdn.net/icansoicrazy/article/details/126391095
https://www.cnblogs.com/strongmore/p/17435714.html
https://juejin.cn/post/7102428103196016671