使用 Maven Java API 从 Repository 检索 Maven Artifact [英] Retrieving Maven Artifact from Repository using Maven Java API

查看:46
本文介绍了使用 Maven Java API 从 Repository 检索 Maven Artifact的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有 Maven Artifact 信息(GroupId、ArtifactId、Version),我如何以编程方式(使用 Java)从我的本地存储库中检索该 Artifact?

If I have a Maven Artifact information (GroupId, ArtifactId, Version) how can I programmatically (using Java) retrieve that Artifact from my local repository?

具体来说,我需要能够连接到 Maven 存储库并创建/检索 org.apache.maven.artifact.Artifact,以便我可以检索与工件关联的文件.

Specifically, I need to be able to connect to the Maven Repository and create/retrieve a org.apache.maven.artifact.Artifact so I can retrieve the file associated with the Artifact.

我查看了 m2e 源代码,但 MavenImpl.java(提供工件解析)比我需要的要复杂得多,而且很难理解与存储库的连接是如何工作的.

I have looked into m2e source code, but the MavenImpl.java (which provides Artifact resolution) is way more complex than what I need and it is difficult to understand how the connection to the repository works.

推荐答案

你可能想看看 以太.有关示例,请参阅 Wiki.

You'll probably want to look at Aether. See the Wiki for examples.

这篇关于使用 Maven Java API 从 Repository 检索 Maven Artifact的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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