使用maven发布jar包到github

技术 置顶 精帖
0 527
peng49
peng49 2021-06-26 16:50:12
 

github生成发布需要用到的token

配置 settings.xml 文件

添加如下内容

  1. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
  4. http://maven.apache.org/xsd/settings-1.0.0.xsd">
  5. <activeProfiles>
  6. <activeProfile>github</activeProfile>
  7. </activeProfiles>
  8. <profiles>
  9. <profile>
  10. <id>github</id>
  11. <repositories>
  12. <repository>
  13. <id>central</id>
  14. <url>https://repo1.maven.org/maven2</url>
  15. </repository>
  16. <repository>
  17. <id>github</id>
  18. <url>https://maven.pkg.github.com/用户名/*</url>
  19. <snapshots>
  20. <enabled>true</enabled>
  21. </snapshots>
  22. </repository>
  23. </repositories>
  24. </profile>
  25. </profiles>
  26. <servers>
  27. <server>
  28. <id>github</id>
  29. <username>用户名</username>
  30. <password>生成的token</password>
  31. </server>
  32. </servers>
  33. </settings>

修改pom.xml文件

添加如下内容

  1. <distributionManagement>
  2. <repository>
  3. <id>github</id>
  4. <name>GitHub OWNER Apache Maven Packages</name>
  5. <url>https://maven.pkg.github.com/github用户名/仓库</url>
  6. </repository>
  7. </distributionManagement>

发布

mvn deploy

或者添加 -Dmaven.test.skip=true 跳过测试

mvn deploy -Dmaven.test.skip=true

回帖
登录
忘记密码?