如何从 Maven 存储库中找到最新版本的工件 [英] How do I find the latest version of an artifact from a maven repository

查看:43
本文介绍了如何从 Maven 存储库中找到最新版本的工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为自动化部署的一部分,我需要一个脚本来从我们的内部存储库下载最新版本的工件.

As part of an automated deployment I need a script to download the latest version of an artifact from our internal repository.

理想情况下,此脚本将使用 ant 或 unix shell 脚本.

Ideally this script will be with ant or a unix shell script.

例如:

我有 myArtifact.war,它有 1.0、1.1 和 2.0 版本 - 我需要给定正确组 ID 和工件 ID 的脚本,以便从我们的 maven 存储库(当前使用 artifactory)检索 2.0 版.

I have myArtifact.war and it has versions 1.0 , 1.1 and 2.0 - I need the script given the correct group id and artifact id to retrieve version 2.0 from our maven repository (currently using artifactory).

有没有什么简单的方法可以做到这一点?

Is there any easy way to do this?

推荐答案

您可以解析 maven-metadata.xml 以查看可用的版本,以及哪个版本是发布"版本.有关更多信息,请参阅有关插件版本的答案详情.

You can parse the maven-metadata.xml to see what versions are available, and which version is the "release" version. See this answer about plugin versions for more details.

如果您使用的是 Nexus,则可以使用 REST API 查询存储库.您还可以使用 REST 客户端 API 来简化您的处理.

If you are using Nexus, you can use the REST API to query the repository. You can also use the REST client API to simplify your processing.

要更新发布版本,请激活 Maven 超级 POM 当您执行 mvn deploy 时.您可以通过在命令行中添加 -Prelease-profile-DperformRelease=true 来实现这一点.

To update the release version, activate the release-profile in the Maven super POM when you do mvn deploy. You can do this by adding -Prelease-profile or -DperformRelease=true to the command line.

默认情况下,在 maven-release-plugin 的执行目标中激活配置文件.它由 useReleaseProfile 属性控制.有关更多详细信息,请参阅 release-perform 目标文档.

The profile is activate by default in the maven-release-plugin's perform goal. It is controlled by the useReleaseProfile property. See the release-perform goal's documentation for more details.

这篇关于如何从 Maven 存储库中找到最新版本的工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆