【问题标题】:Releasing to Maven Central发布到 Maven 中心
【发布时间】:2015-02-24 20:29:09
【问题描述】:

我被添加为 Maven 项目的开发人员,现在我需要发布。 我已将nexus-staging-maven-plugin 添加到pom.xml 文件中。

<plugin>
  <groupId>org.sonatype.plugins</groupId>
  <artifactId>nexus-staging-maven-plugin</artifactId>
  <version>1.6.3</version>
  <extensions>true</extensions>
  <configuration>
    <serverId>ossrh</serverId>
    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
    <autoReleaseAfterClose>true</autoReleaseAfterClose>
  </configuration>
</plugin>

我还添加了distributionManagementpom.xml

<distributionManagement>
  <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>

我已将我的凭据发送至~/.m2/settings.xml

<settings>
  <servers>
    <server>
      <id>ossrh</id>
      <username>divanov-oss.sonatype.org-account</username>
      <password>divanov-oss.sonatype.org-password</password>
    </server>
  </servers>
</settings>

我还尝试在 oss.sonatype.org 上创建和使用“访问用户令牌” 作为我的凭据。

现在我正在执行将发布部署到 maven Central。

mvn clean deploy

最终出现错误:

[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.3:deploy
(injected-nexus-deploy) on project project: Failed to deploy artifacts:
Could not transfer artifact
project:jar:4.4.0-20141228.104011-1 from/to ossrh
(https://oss.sonatype.org/content/repositories/snapshots): Access denied to:
https://oss.sonatype.org/content/repositories/snapshots/project/project/4.4.0-SNAPSHOT/project-4.4.0-20141228.104011-1.jar,
ReasonPhrase: Forbidden. -> [Help 1]

[INFO] Performing remote staging...
[INFO] 
[INFO]  * Remote staging into staging profile ID "329a0bc2b7ce06"
[ERROR] Remote staging finished with a failure: 403 - Forbidden
[ERROR] 
[ERROR] Possible causes of 403 Forbidden:
[ERROR]  * you have no permissions to stage against profile with ID "329a0bc2b7ce06"? Get to Nexus admin...

如何在我尝试发布的 Maven 项目中检查我的访问权限?

【问题讨论】:

  • 根据您的配置,快照和阶段存储库有两个相同的 ID。我不建议这样做。除此之外,您是否尝试使用给定的凭据登录 oss nexus ?此外,您为什么使用 nexus-staging 插件而不是通常的部署插件?
  • 我按照 Apache Maven 文档central.sonatype.org/pages/apache-maven.html 在示例中使用相同的 ID。他们的建议错了吗?
  • 再过一次。您是否尝试使用给定的凭据登录?成功了吗?
  • 我可以在这里登录:oss.sonatype.org。但我无法登录我已安装并启动的本地 Nexus OSS。 “用户名、密码不正确或无权使用 Nexus 用户界面。重试。请先登录,然后再尝试进一步请求。”我不确定是否需要本地 Nexus OSS 才能发布到远程存储库。
  • 我可以在这里登录:oss.sonatype.org。但我无法使用相同的凭据登录我的本地 Nexus OSS。我不确定是否需要本地 Nexus OSS 才能发布到远程存储库。

标签: maven maven-3 sonatype maven-central


【解决方案1】:

您的凭据可能没有问题,如果不是,您会收到 401 错误。你得到403(禁止)。这意味着凭据已被接受,但您无权发布工件。最常见的原因是您使用的 Maven 组 ID 与分配给您的组 ID 不同。在“社区支持 - 开源项目存储库托管”中向 https://issues.sonatype.org 提交问题,我们会解决这个问题。

【讨论】:

  • 我已向issues.sonatype.org 提交了一个错误。我得到了 Maven 管理员整理的权限。感谢他们。但是,我仍然不知道这是否是找出和更改权限的唯一方法?
【解决方案2】:

您需要使用的凭据不应该是 Sonatype JIRA,而是 oss.sonatype.org。您需要在那里单独注册。

[更新]问题已更改,因此此答案不再相关。我会保留它,因为这是一个常见的错误。

【讨论】:

  • 看着这一切的疯狂,让我建议你using Bintray for that。容易得多。
  • 我不记得单独注册了,但我有相同的 JIRA 和 oss.sonatype.org 凭据集。我什至尝试在 oss.sonatype.org 上创建和使用“访问用户令牌”。
  • 问题是:“如何检查我在尝试发布的 Maven 项目中的访问权限?”坦率地说,这个问题仍然没有答案。
  • 嗯,它是 Sonatype ......所以你问他们,那里没有多少选择。
猜你喜欢
  • 2016-08-22
  • 2020-02-01
  • 1970-01-01
  • 2015-05-04
  • 1970-01-01
  • 2020-11-13
  • 2015-05-20
  • 2016-02-29
  • 1970-01-01
相关资源
最近更新 更多