我正在尝试将Maven软件包发布到github软件包注册表中。我正在按照这些步骤。 https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages
在我的.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">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers>
<server>
<id>github</id>
<username>my github username </username>
<password>a github personal access token I created</password>
</server>
</servers>
<mirrors/>
<proxies/>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<name>GitHub my github username Apache Maven Packages</name>
<url>https://maven.pkg.github.com/mygithubusername/the repository name</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles/>
</settings>
在项目的pom.xml文件中,我修改了此块。注释掉了sonatype代码,该代码将项目保存在Maven Central中,并添加了用于发布到github注册表中的必要代码。
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub myGithubUsername Apache Maven Packages</name>
<url>https://maven.pkg.github.com/myGithubUsername/githubReposit</url>
</repository>
<!--
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
-->
</distributionManagement>
当我以普通的Maven安装运行时,没有错误,但是在存储库中未创建任何软件包。这不是100%准确的:我曾经以某种方式确实生成了一个程序包,却不知道自己在使一次有效地执行什么魔术。由于存储库中现在有一个软件包,所以我担心我的安装不再创建或更新此软件包的原因是,当我导航到github帐户上的软件包页面时,注释说该软件包是在2小时前添加的并且尚未再次添加或更新。
我尝试将Eclipse运行配置目标修改为
deploy -Dregistry=https://maven.pkg.github.com/[org] -Dtoken= <my personal access token>
类似于这篇文章,但有不同的错误。 Exception while trying to deploy Maven build JAR to github package registry
这产生了错误...
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) on project <projectname>.core: Execution injected-nexus-deploy of goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy failed: Server credentials with ID "ossrh" not found! -> [Help 1]
但是,我无法在pom.xml文件中定义ossrh以及保存到github软件包注册表所需的行。
有人可以指点我更多文档或在这里解释我所缺少的内容吗。
欢呼