部署到 nexus 时 maven-metadata.xml 未更新

发布于 2024-10-15 17:51:29 字数 3480 浏览 8 评论 0原文

我正在使用 Apache Maven 3.0 Nexus 开源版,版本:1.8.0.1

这是我的 pom.xml 的一部分,

<plugin>
   <artifactId>maven-deploy-plugin</artifactId>
   <version>2.5</version>
</plugin>
<plugin>
   <artifactId>maven-release-plugin</artifactId>
   <version>2.1</version>
</plugin>

<distributionManagement>
   <repository>
   <id>nexus</id>
   <name>nexus</name>
   <url>http://myrepo/nexus/content/repositories/releases</url>
   </repository>
</distributionManagement>

它是一个非常简单的项目。当我做的

  mvn release:prepare
  mvn release:perform

一切都运行良好:

...
[INFO] [INFO] --- maven-deploy-plugin:2.5:deploy (default-deploy) @ simple ---
[INFO] Uploading: http://myrepo/nexus/content/repositories/releases/...pom
[INFO] 4 KB   
[INFO] 5 KB   
[INFO]        
[INFO] Uploaded: http://myrepo/nexus/content/repositories/releases/....pom (5 KB at 1.0 KB/sec)
[INFO] Downloading: http://myrepo/nexus/content/repositories/releases/.../maven-metadata.xml
[INFO] 603 B   
[INFO]         
[INFO] Downloaded: http://myrepo/nexus/content/repositories/releases/.../maven-metadata.xml (603 B at 1.5 KB/sec)
[INFO] Uploading: http://myrepo/nexus/content/repositories/releases/.../maven-metadata.xml
[INFO] 634 B   
[INFO]         
[INFO] Uploaded: http://myrepo/nexus/content/repositories/.../maven-metadata.xml (634 B at 1.6 KB/sec)

现在我下载 http://myrepo/nexus/content/repositories/ .../maven-metadata.xml 它看起来像这样:

<metadata>
<groupId>simple</groupId>
<artifactId>simple</artifactId>
<versioning>
<latest>0.5.8</latest>
<release>0.5.8</release>
<versions>
<version>0.5.9</version>
<version>0.1</version>
<version>0.3</version>
<version>0.4</version>
<version>0.5.1</version>
<version>0.5.2</version>
<version>0.5.3</version>
<version>0.5.4</version>
<version>0.5.5</version>
<version>0.5.6</version>
<version>0.5.7</version>
<version>0.5.8</version>
</versions>
<lastUpdated>20110202190804</lastUpdated>
</versioning>
</metadata>

我的最新和刚刚发布的版本没有标记为“最新”和“发布”。

现在我在 Nexus WebUI 中执行“重建元数据”。此后我再次下载元数据。现在看起来像这样

<metadata>
  <groupId>simple</groupId>
  <artifactId>simple</artifactId>
  <versioning>
    <latest>0.5.9</latest>
    <release>0.5.9</release>
    <versions>
      <version>0.1</version>
      <version>0.3</version>
      <version>0.4</version>
      <version>0.5.1</version>
      <version>0.5.2</version>
      <version>0.5.3</version>

      <version>0.5.4</version>
      <version>0.5.5</version>
      <version>0.5.6</version>
      <version>0.5.7</version>
      <version>0.5.8</version>
      <version>0.5.9</version>

    </versions>
    <lastUpdated>20110202191117</lastUpdated>
  </versioning>
</metadata>

这看起来像是 Nexus 或 Maven 中的错误?有人有解决方案吗?

i am using Apache Maven 3.0
Nexus Open Source Edition, Version: 1.8.0.1

this is part of my pom.xml

<plugin>
   <artifactId>maven-deploy-plugin</artifactId>
   <version>2.5</version>
</plugin>
<plugin>
   <artifactId>maven-release-plugin</artifactId>
   <version>2.1</version>
</plugin>

<distributionManagement>
   <repository>
   <id>nexus</id>
   <name>nexus</name>
   <url>http://myrepo/nexus/content/repositories/releases</url>
   </repository>
</distributionManagement>

it is a very simple project. when i do

  mvn release:prepare
  mvn release:perform

everything runs fine:

...
[INFO] [INFO] --- maven-deploy-plugin:2.5:deploy (default-deploy) @ simple ---
[INFO] Uploading: http://myrepo/nexus/content/repositories/releases/...pom
[INFO] 4 KB   
[INFO] 5 KB   
[INFO]        
[INFO] Uploaded: http://myrepo/nexus/content/repositories/releases/....pom (5 KB at 1.0 KB/sec)
[INFO] Downloading: http://myrepo/nexus/content/repositories/releases/.../maven-metadata.xml
[INFO] 603 B   
[INFO]         
[INFO] Downloaded: http://myrepo/nexus/content/repositories/releases/.../maven-metadata.xml (603 B at 1.5 KB/sec)
[INFO] Uploading: http://myrepo/nexus/content/repositories/releases/.../maven-metadata.xml
[INFO] 634 B   
[INFO]         
[INFO] Uploaded: http://myrepo/nexus/content/repositories/.../maven-metadata.xml (634 B at 1.6 KB/sec)

Now i download http://myrepo/nexus/content/repositories/.../maven-metadata.xml
it looks like this:

<metadata>
<groupId>simple</groupId>
<artifactId>simple</artifactId>
<versioning>
<latest>0.5.8</latest>
<release>0.5.8</release>
<versions>
<version>0.5.9</version>
<version>0.1</version>
<version>0.3</version>
<version>0.4</version>
<version>0.5.1</version>
<version>0.5.2</version>
<version>0.5.3</version>
<version>0.5.4</version>
<version>0.5.5</version>
<version>0.5.6</version>
<version>0.5.7</version>
<version>0.5.8</version>
</versions>
<lastUpdated>20110202190804</lastUpdated>
</versioning>
</metadata>

my latest and just released version is not marked as "latest" and "release".

Now i do "Rebuild Metadata" inside Nexus WebUI. I download metadata after this again. It looks now like this

<metadata>
  <groupId>simple</groupId>
  <artifactId>simple</artifactId>
  <versioning>
    <latest>0.5.9</latest>
    <release>0.5.9</release>
    <versions>
      <version>0.1</version>
      <version>0.3</version>
      <version>0.4</version>
      <version>0.5.1</version>
      <version>0.5.2</version>
      <version>0.5.3</version>

      <version>0.5.4</version>
      <version>0.5.5</version>
      <version>0.5.6</version>
      <version>0.5.7</version>
      <version>0.5.8</version>
      <version>0.5.9</version>

    </versions>
    <lastUpdated>20110202191117</lastUpdated>
  </versioning>
</metadata>

This looks like a bug in nexus or in maven? Does anybody has a solution for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那片花海 2024-10-22 17:51:29

您是否尝试过在部署插件配置中将 updateReleaseInfo 设置为 true ?

<plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.5</version>
    <configuration>
        <updateReleaseInfo>true</updateReleaseInfo>
    </configuration>
</plugin>

注意,我没有尝试过这个,只是当我读到这个问题时碰巧打开了部署插件文档,这似乎是合理的。

来自 Maven 文档

updateReleaseInfo:
Parameter used to update the metadata to make the artifact as release.

Type: boolean
Required: No
Expression: ${updateReleaseInfo}
Default: false

Have you tried setting updateReleaseInfo to true in your deploy plugin configuration?

<plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.5</version>
    <configuration>
        <updateReleaseInfo>true</updateReleaseInfo>
    </configuration>
</plugin>

Note, I haven't tried this, just happened to have the deploy plugin docs open when I read this question and it seems reasonable.

From the Maven docs:

updateReleaseInfo:
Parameter used to update the metadata to make the artifact as release.

Type: boolean
Required: No
Expression: ${updateReleaseInfo}
Default: false
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文