问题描述
如果我有 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.
推荐答案
You'll probably want to look at Aether. See the Wiki for examples.
这篇关于使用 Maven Java API 从 Repository 检索 Maven Artifact的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!