java 在 Maven 存储库中查找特定插件的可用版本列表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1374064/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Finding list of versions available in a Maven repository for a specific plugin?
提问by Jared
Given the following repository URL from my pom.xml how can I determine what the latest versions of spring and hibernate are available in the repository? http://repo1.maven.org/maven2
鉴于我的 pom.xml 中的以下存储库 URL,我如何确定存储库中可用的最新版本的 spring 和 hibernate? http://repo1.maven.org/maven2
采纳答案by matt b
Programatically or just manually?
以编程方式还是仅手动?
Since the repository works over HTTP you can just navigate it manually:
由于存储库通过 HTTP 工作,您可以手动导航它:
http://repo2.maven.org/maven2/org/springframework/spring/http://repo2.maven.org/maven2/org/hibernate/hibernate/http://repo2.maven.org/maven2/org/hibernate/hibernate-core/
http://repo2.maven.org/maven2/org/springframework/spring/ http://repo2.maven.org/maven2/org/hibernate/hibernate/ http://repo2.maven.org/maven2/org/休眠/休眠核心/
回答by Robert Munteanu
Retrieve the maven-metadata.xmlfile, placed in the artifact directory, e.g. http://repo1.maven.org/maven2/com/sun/media/jai_codec/maven-metadata.xmlfor an artefact with the groupId com.sun.mediaand artifactId jai_codec.
检索maven-metadata.xml放置在工件目录中的文件,例如http://repo1.maven.org/maven2/com/sun/media/jai_codec/maven-metadata.xml以获取具有 groupIdcom.sun.media和 artifactId 的工件jai_codec。
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.example</groupId>
<artifactId>project</artifactId>
<versioning>
<latest>0.0.5</latest>
<release>0.0.5</release>
<versions>
<version>0.0.3</version>
<version>0.0.4</version>
<version>0.0.5</version>
</versions>
<lastUpdated>20090725212606</lastUpdated>
</versioning>
</metadata>
回答by Rich Seller
As Robert's answer says, the maven-metadata.xml file for each artifact in the repository holds the version information you need. In particular note the latestand releaseelements in the metadata. The latest element denotes the last version to be published, this may not be the version you want though. For example it could be a maintenance release to an older version, a release candidate, or a milestone. The release version denotes the last published version intended to be treated as a release, so generally you'd want to take this version.
正如罗伯特的回答所说,存储库中每个工件的 maven-metadata.xml 文件包含您需要的版本信息。特别注意元数据中的最新和发布元素。最新元素表示要发布的最后一个版本,但这可能不是您想要的版本。例如,它可以是旧版本的维护版本、候选版本或里程碑。发布版本表示最后发布的版本,打算被视为一个版本,所以通常你会想要使用这个版本。
For information the Maven super POMhas a special release-profileprofile, activated by setting the performReleaseproperty (e.g. by passing -DperformRelease on the command line). Amongst other things, activating this property will set the updateReleaseInfoproperty of the deploy-plugin so that the metadata will be updated when you deploy.
有关信息,Maven 超级 POM有一个特殊的发布配置文件,通过设置performRelease属性激活(例如通过在命令行上传递 -DperformRelease)。除其他外,激活此属性将设置deploy-plugin的updateReleaseInfo属性,以便在您部署时更新元数据。
回答by user2189998
Depending on what the real use case is, it can be worth looking at http://www.mojohaus.org/versions-maven-plugin/
根据实际用例是什么,值得一看 http://www.mojohaus.org/versions-maven-plugin/

