github在被大微软收购之后,推出了很多非常不错的功能,这一次把很多仓库管理合并到一起了,包括了nuget,npm,maven,docker等等,今天我们把java代码推到github的maven仓库吧!

申请一个github token

建立一个仓库,起名为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>

在项目pom.xml里指定它,发布者和使用者都需要配置

<distributionManagement>
   <repository>
     <id>github</id>
     <name>GitHub OWNER Apache Maven Packages</name>
     <url>https://maven.pkg.github.com/bfyxzls/maven_repo</url>
   </repository>
</distributionManagement>

发布你的包到github packages

mvn deploy

你最终发布的包在这里

参考文章

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/lori/p/17351913.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!

相关课程